use ESM module,
use the latest typescript version - 5.6.3,
set "resolveJsonModule": true in the tsconfig.json,
in an source file with the tested functionality put something like this:
import { name } from '../package.json' with { type: 'json' };
console.log(name);
start a test suit, which tests functionality in the file changed before
Expected behavior
tests from the test suit are started
Actual behavior
● Test suite failed to run
SyntaxError: The requested module '../package.json' does not provide an export named 'name'
at Runtime.linkAndEvaluateModule (../../../../node_modules/jest-runtime/build/index.js:708:5)
Additional context
workaround: instead of the named import, import whole json object:
import pkgJson from '../package.json' with { type: 'json' };
console.log(pkgJson.name);
Version
29.7.0
Steps to reproduce
use ESM module, use the latest typescript version - 5.6.3, set
"resolveJsonModule": true
in the tsconfig.json, in an source file with the tested functionality put something like this:start a test suit, which tests functionality in the file changed before
Expected behavior
tests from the test suit are started
Actual behavior
● Test suite failed to run
Additional context
workaround: instead of the named import, import whole json object:
Environment