Skip to content

Commit 36cda00

Browse files
committed
add import JSON test
1 parent 4e2ad6d commit 36cda00

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ts-node-dev",
3-
"version": "1.0.0-pre.51",
3+
"version": "1.0.0-pre.52",
44
"description": "Compiles your TS app and restarts when files are modified.",
55
"keywords": [
66
"restart",

test/fixture/import-json.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import * as data from './file.json'
2+
3+
console.log('JSON DATA:', data)

test/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,21 @@ test('It handles allowJs option and loads JS modules', async (t) => {
140140
await ps.exit()
141141
})
142142

143+
test('It handles resolveJsonModule option and loads JSON modules', async (t) => {
144+
const cOptions = { resolveJsonModule: true }
145+
const ps = spawnTsNodeDev(
146+
[
147+
`--respawn`,
148+
`--compiler ttypescript`,
149+
`--compiler-options=${JSON.stringify(cOptions)}`,
150+
`import-json`,
151+
].join(' ')
152+
)//.turnOnOutput()
153+
await ps.waitForLine(/JSON DATA: { file: 'json' }/)
154+
t.pass('ok')
155+
await ps.exit()
156+
})
157+
143158
test('It allows to use TS Transformers', async (t) => {
144159
const cOptions = { plugins: [{ transform: 'ts-nameof', type: 'raw' }] }
145160
const ps = spawnTsNodeDev(

0 commit comments

Comments
 (0)