Skip to content

Commit b4be421

Browse files
committed
(test): ensure node env w/ localStorage errors out
- add node test to reach 100% code coverage! - would prefer this test be in the same file as the others, but unfortunately jest only allows setting jest-environment on a per file basis, not on a per test or per test suite basis :/
1 parent bca0f17 commit b4be421

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/index.node.spec.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @jest-environment node
3+
*/
4+
// add tests in this file that are specific to node (vs. jsdom)
5+
6+
/// <reference types="@types/jest" />
7+
8+
import { persist } from '../src/index'
9+
import { UserStoreF } from './fixtures'
10+
11+
describe('node usage', () => {
12+
it('should error on default localStorage usage', async () => {
13+
const user = UserStoreF.create()
14+
await expect(persist('user', user)).rejects.toMatch(/^localStorage.+$/)
15+
})
16+
})

0 commit comments

Comments
 (0)