diff --git a/.eslintrc.json b/.eslintrc.json index d8dd055..26f5eae 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -2,7 +2,8 @@ "plugins": [], "ignorePatterns": [ "dist", - "importsJSONfile.js" + "importsJSONfile.with.js", + "importsJSONfile.assert.legacy.js" ], "extends": [ "eslint:recommended", diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7e4b7b5..ceb2e2d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,8 +13,11 @@ jobs: strategy: fail-fast: false matrix: - node-version: [18.x, 20.x, 21.x, 22.x] + node-version: [18.x, 20.x, 22.x] os: [ubuntu-latest, windows-latest] + exclude: + - os: windows-latest + node-version: 22.x steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index adc0bf5..5210f65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # changelog + * 2.6.5 _Apr.25.2024_ + * [add node 22 to ci test pipeline](https://github.com/iambumblehead/esmock/pull/297) thanks @aladdin-add + * [use json import syntax `with { type: 'json' }`](https://github.com/iambumblehead/esmock/pull/298) for node 22 + * [skip node 22 tests on windows-latest ci,](https://github.com/iambumblehead/esmock/pull/298) where node 22 is in a broken state, see [nodejs/node#52682](https://github.com/nodejs/node/issues/52682) * 2.6.4 _Feb.26.2024_ * [update README with notice](https://github.com/iambumblehead/resolvewithplus/pull/295) about incompatible typescript loaders * [increment resolvewithplus](https://github.com/iambumblehead/resolvewithplus/pull/295) to support more export patterns, see [resolvewithplus v2.1.5](https://github.com/iambumblehead/resolvewithplus/releases/tag/v2.1.5) diff --git a/tests/local/importsJSONfile.js b/tests/local/importsJSONfile.assert.legacy.js similarity index 100% rename from tests/local/importsJSONfile.js rename to tests/local/importsJSONfile.assert.legacy.js diff --git a/tests/local/importsJSONfile.with.js b/tests/local/importsJSONfile.with.js new file mode 100644 index 0000000..00f036b --- /dev/null +++ b/tests/local/importsJSONfile.with.js @@ -0,0 +1,5 @@ +import JSONobj from './example.json' with { type: 'json' }; + +export { + JSONobj +} diff --git a/tests/tests-node/esmock.node.test.js b/tests/tests-node/esmock.node.test.js index 3992d14..40c59c7 100644 --- a/tests/tests-node/esmock.node.test.js +++ b/tests/tests-node/esmock.node.test.js @@ -550,15 +550,14 @@ test('should mock an exported array', async () => { }) test('should mock imported json', async () => { - const importsJSON = await esmock( - '../local/importsJSONfile.js', { - '../local/example.json': { - 'test-example': 'test-json-a' - } - }) - - if (/^(18|20)$/.test(process.versions.node.split('.')[0])) - return assert.ok(true) + const importsJSONPath = 20 <= +process.versions.node.split('.')[0] + ? '../local/importsJSONfile.with.js' + : '../local/importsJSONfile.assert.legacy.js' + const importsJSON = await esmock(importsJSONPath, { + '../local/example.json': { + 'test-example': 'test-json-a' + } + }) assert.strictEqual( Object.keys(importsJSON.JSONobj).sort().join(), 'example,test-example') @@ -567,15 +566,14 @@ test('should mock imported json', async () => { }) test('should mock imported json (strict)', async () => { - const importsJSON = await esmock.strict( - '../local/importsJSONfile.js', { - '../local/example.json': { - 'test-example': 'test-json-b' - } - }) - - if (/^(18|20)$/.test(process.versions.node.split('.')[0])) - return assert.ok(true) + const importsJSONPath = 20 <= +process.versions.node.split('.')[0] + ? '../local/importsJSONfile.with.js' + : '../local/importsJSONfile.assert.legacy.js' + const importsJSON = await esmock.strict(importsJSONPath, { + '../local/example.json': { + 'test-example': 'test-json-b' + } + }) assert.strictEqual( Object.keys(importsJSON.JSONobj).sort().join(), 'test-example')