Closed FreePhoenix888 closed 2 weeks ago
I think I have encountered a related issue:
> ###@1.9.0 test
> node --no-warnings=ExperimentalWarning --experimental-import-meta-resolve --loader ts-node/esm/transpile-only --max-old-space-size=8192 ./node_modules/jest/bin/jest.js formsection
FAIL ### packages/guidebook-widget/src/components/GuidebookModal/FormView/FormSection/FormSection.spec.tsx
● Test suite failed to run
packages/guidebook-widget/src/components/GuidebookModal/FormView/FormSection/FormSection.tsx:29:68 - error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.
29 import translations from '../../../../config/translations/de.json' assert { type: 'json' }
~~~~~~~~~~~~~~~~~~~~~~~
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 8.535 s
(I've used #
to replace confidential data)
ESM is used all across the project (the package type is module
).
System:
OS: Linux 5.14 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish)
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
Binaries:
Node: 20.5.0 - /usr/bin/node
Yarn: 1.22.15 - /usr/bin/yarn
npm: 9.8.0 - /usr/bin/npm
npmPackages:
jest: ^29.0.0 => 29.6.2
I'm also attaching the Jest config and resolver and the tsconfig.
Jest can only process this under ESM mode. You can check documentation how to configure it https://kulshekhar.github.io/ts-jest/docs/guides/esm-support
Added e2e test included this case to prove the latest version works with this, see https://github.com/kulshekhar/ts-jest/blob/main/e2e/esm-features/__tests__/esm-features.spec.ts
Please note that only ESNext
would work. Node16/NodeNext
is not supported yet
Version
29.1.1 (latest)
Steps to reproduce
git clone https://github.com/deep-foundation/npm-automation.git
cd npm-automation
git checkout 89153a08e34165a7b4d27730c295cdfd38c0c097
npm clean-intall
npm run test --templateNamePattern "sync"
FAIL tests/sync-dependencies.ts ● Test suite failed to run
Test Suites: 1 failed, 1 total Tests: 0 total Snapshots: 0 total Time: 2.14 s Ran all test suites matching /sync/i.
freephoenix888@freephoenix888:~/Programming/deep/npm-automation$ export TS_JEST_LOG=ts-jest.log && npm run test --templateNamePattern "sync"
FAIL tests/sync-dependencies.ts ● Test suite failed to run
Test Suites: 1 failed, 1 total Tests: 0 total Snapshots: 0 total Time: 2.187 s Ran all test suites matching /sync/i.