Skip to content

Commit 712e5dc

Browse files
committed
test: option globals
1 parent 9bae18e commit 712e5dc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

__tests__/require.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@ it('should work with relative require in file', () => {
1818
expect(res).toBe('hi')
1919
})
2020

21+
it('should work with provided globals', () => {
22+
const res = requireFromString('module.exports = process.cwd()', { process })
23+
expect(res).toBe(process.cwd())
24+
})
25+
2126
it('should have meaningful error message', () => {
2227
expect.assertions(1)
2328
try {
2429
requireFromString("throw new Error('Boom!')")
2530
} catch (err) {
2631
expect(
27-
err.stack.search(/module-from-string\/__tests__\/require\.test\.ts:24:5/)
32+
err.stack.search(/module-from-string\/__tests__\/require\.test\.ts:29:5/)
2833
).toBeGreaterThan(-1)
2934
}
3035
})

0 commit comments

Comments
 (0)