I am converting a node package into pure ESM. I have done the import changes to my files, added "type":"module" to package.json and also used "exports":"./lib/index.js"
When I run the test, I get the this common error:
/x/__tests__/values.test.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import fs from 'fs'
^^^^^^
SyntaxError: Cannot use import statement outside a module
I've looked only, through many examples and Q&A, but almost all of them refers to changes with ts-node or babel. My package is quite simple, it does not use babel and it's plain javascript.
I am getting a bit stuck here, because I am nearly sure it's not a bug, but also I can't fix it.
I do not have any transform or transformIgnorePatterns. The test import section is
import fs from 'fs'
import { values } from "../lib/index.js"
const expectedData = JSON.parse(fs.readFileSync(__dirname + "/testfiles/values.output.json"))
Jest is version 29.0.1
Node is version 16.17.0