Skip to content

Instantly share code, notes, and snippets.

@davidjb
Last active January 3, 2024 09:19
Show Gist options
  • Save davidjb/6c6492848dc924a9551b1e2d97f8a847 to your computer and use it in GitHub Desktop.
Save davidjb/6c6492848dc924a9551b1e2d97f8a847 to your computer and use it in GitHub Desktop.

Manually update @amcharts/amcharts5/package.json with "type": "module", then run:

npm t

> amcharts-demo@1.0.0 test
> NODE_OPTIONS="--experimental-vm-modules" jest

(node:26882) ExperimentalWarning: VM Modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:26882) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
 PASS  ./chart.test.mjs
  ✓ example (53 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        0.401 s, estimated 1 s
Ran all test suites.
import * as am5 from '@amcharts/amcharts5';
test('example', async () => {
const chart = await import('./chart.mjs');
expect(chart).toMatchObject({})
})
{
"name": "amcharts-demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest"
},
"author": "",
"license": "ISC",
"dependencies": {
"@amcharts/amcharts5": "^5.4.7",
"jest-environment-jsdom": "^29.7.0"
},
"devDependencies": {
"jest": "^28.1.3"
},
"jest": {
"testMatch": [
"**/__tests__/**/*.?(m)js",
"**/?(*.)+(spec|test).?(m)js"
],
"testEnvironment": "jsdom"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment