From f36d62032df7bda27bdd089e825b55623f0dc3d2 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 25 Apr 2024 10:43:08 -0700 Subject: [PATCH 01/13] skip import json test for node 22 --- tests/tests-node/esmock.node.test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/tests-node/esmock.node.test.js b/tests/tests-node/esmock.node.test.js index 3992d14..83ce4d6 100644 --- a/tests/tests-node/esmock.node.test.js +++ b/tests/tests-node/esmock.node.test.js @@ -550,6 +550,9 @@ test('should mock an exported array', async () => { }) test('should mock imported json', async () => { + if (/^22$/.test(process.versions.node.split('.')[0])) + return assert.ok(true) + const importsJSON = await esmock( '../local/importsJSONfile.js', { '../local/example.json': { @@ -567,6 +570,9 @@ test('should mock imported json', async () => { }) test('should mock imported json (strict)', async () => { + if (/^22$/.test(process.versions.node.split('.')[0])) + return assert.ok(true) + const importsJSON = await esmock.strict( '../local/importsJSONfile.js', { '../local/example.json': { From 1eb91f199ca9d00f3f79bddacf0fca7555d07f50 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 25 Apr 2024 11:05:51 -0700 Subject: [PATCH 02/13] use with import syntax for importing json in node 22 --- CHANGELOG.md | 3 ++ ...le.js => importsJSONfile.assert.legacy.js} | 0 tests/local/importsJSONfile.with.js | 5 +++ tests/tests-node/esmock.node.test.js | 34 +++++++++---------- 4 files changed, 24 insertions(+), 18 deletions(-) rename tests/local/{importsJSONfile.js => importsJSONfile.assert.legacy.js} (100%) create mode 100644 tests/local/importsJSONfile.with.js diff --git a/CHANGELOG.md b/CHANGELOG.md index adc0bf5..88e09ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # 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 * 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 83ce4d6..aa4c4cb 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 () => { - if (/^22$/.test(process.versions.node.split('.')[0])) - return assert.ok(true) - - const importsJSON = await esmock( - '../local/importsJSONfile.js', { - '../local/example.json': { - 'test-example': 'test-json-a' - } - }) + const importsJSONPath = 22 >= +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' + } + }) if (/^(18|20)$/.test(process.versions.node.split('.')[0])) return assert.ok(true) @@ -570,15 +569,14 @@ test('should mock imported json', async () => { }) test('should mock imported json (strict)', async () => { - if (/^22$/.test(process.versions.node.split('.')[0])) - return assert.ok(true) - - const importsJSON = await esmock.strict( - '../local/importsJSONfile.js', { - '../local/example.json': { - 'test-example': 'test-json-b' - } - }) + const importsJSONPath = 22 >= +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' + } + }) if (/^(18|20)$/.test(process.versions.node.split('.')[0])) return assert.ok(true) From f2ef13d3a944754640b8834805adc58d8408008f Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 25 Apr 2024 11:08:24 -0700 Subject: [PATCH 03/13] update .eslintrc.json --- .eslintrc.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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", From 48415a5302142e3246799691d306a9873f3f6e93 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 25 Apr 2024 11:11:03 -0700 Subject: [PATCH 04/13] add directive, skip node 22 windows-latest --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7e4b7b5..7b4b1fb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,6 +15,9 @@ jobs: matrix: node-version: [18.x, 20.x, 21.x, 22.x] os: [ubuntu-latest, windows-latest] + exclude: + - os: windows-latest + node: 22.x steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 From 9ed7c316925a78a16a4a7d098383dc7059813ad3 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 25 Apr 2024 11:13:43 -0700 Subject: [PATCH 05/13] add directive, skip node 22 windows-latest --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7b4b1fb..de9017f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: os: [ubuntu-latest, windows-latest] exclude: - os: windows-latest - node: 22.x + node-version: 22 steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 From 671b1e9a9bafcf63d53bf4041492ec981092b984 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 25 Apr 2024 11:16:02 -0700 Subject: [PATCH 06/13] add directive, skip node 22 windows-latest --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index de9017f..61a7d62 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: os: [ubuntu-latest, windows-latest] exclude: - os: windows-latest - node-version: 22 + node-version: 22.x steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 From 802b7e6ef6f2a22bd32529e5159445a6546bf557 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 25 Apr 2024 11:21:08 -0700 Subject: [PATCH 07/13] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88e09ad..5210f65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * 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) From 82516d641e18e5b1431af19d5aa8c23657f3f84c Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 25 Apr 2024 11:27:02 -0700 Subject: [PATCH 08/13] try using with syntax with node 20 --- tests/tests-node/esmock.node.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/tests-node/esmock.node.test.js b/tests/tests-node/esmock.node.test.js index aa4c4cb..fbc418c 100644 --- a/tests/tests-node/esmock.node.test.js +++ b/tests/tests-node/esmock.node.test.js @@ -550,7 +550,7 @@ test('should mock an exported array', async () => { }) test('should mock imported json', async () => { - const importsJSONPath = 22 >= +process.versions.node.split('.')[0] + const importsJSONPath = 20 >= +process.versions.node.split('.')[0] ? '../local/importsJSONfile.with.js' : '../local/importsJSONfile.assert.legacy.js' const importsJSON = await esmock(importsJSONPath, { @@ -569,7 +569,7 @@ test('should mock imported json', async () => { }) test('should mock imported json (strict)', async () => { - const importsJSONPath = 22 >= +process.versions.node.split('.')[0] + const importsJSONPath = 20 >= +process.versions.node.split('.')[0] ? '../local/importsJSONfile.with.js' : '../local/importsJSONfile.assert.legacy.js' const importsJSON = await esmock.strict(importsJSONPath, { From 69d60b7e24e78d80b950f5a8ecda8a77595fccf2 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 25 Apr 2024 11:30:54 -0700 Subject: [PATCH 09/13] try using with syntax with node 20 --- tests/tests-node/esmock.node.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/tests-node/esmock.node.test.js b/tests/tests-node/esmock.node.test.js index fbc418c..ecf8e0f 100644 --- a/tests/tests-node/esmock.node.test.js +++ b/tests/tests-node/esmock.node.test.js @@ -550,7 +550,7 @@ test('should mock an exported array', async () => { }) test('should mock imported json', async () => { - const importsJSONPath = 20 >= +process.versions.node.split('.')[0] + const importsJSONPath = 20 <= +process.versions.node.split('.')[0] ? '../local/importsJSONfile.with.js' : '../local/importsJSONfile.assert.legacy.js' const importsJSON = await esmock(importsJSONPath, { @@ -569,7 +569,7 @@ test('should mock imported json', async () => { }) test('should mock imported json (strict)', async () => { - const importsJSONPath = 20 >= +process.versions.node.split('.')[0] + const importsJSONPath = 20 <= +process.versions.node.split('.')[0] ? '../local/importsJSONfile.with.js' : '../local/importsJSONfile.assert.legacy.js' const importsJSON = await esmock.strict(importsJSONPath, { From afb1b4f13527ea535564a3398ea8f1eb523d5228 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 25 Apr 2024 11:33:45 -0700 Subject: [PATCH 10/13] try not skipping json import test with node 20 --- tests/tests-node/esmock.node.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/tests-node/esmock.node.test.js b/tests/tests-node/esmock.node.test.js index ecf8e0f..59a3aa1 100644 --- a/tests/tests-node/esmock.node.test.js +++ b/tests/tests-node/esmock.node.test.js @@ -559,7 +559,7 @@ test('should mock imported json', async () => { } }) - if (/^(18|20)$/.test(process.versions.node.split('.')[0])) + if (/^(18)$/.test(process.versions.node.split('.')[0])) return assert.ok(true) assert.strictEqual( @@ -578,7 +578,7 @@ test('should mock imported json (strict)', async () => { } }) - if (/^(18|20)$/.test(process.versions.node.split('.')[0])) + if (/^(18)$/.test(process.versions.node.split('.')[0])) return assert.ok(true) assert.strictEqual( From efcf307ded1e5eaac3628e784bbace0efb15aef1 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 25 Apr 2024 11:37:30 -0700 Subject: [PATCH 11/13] try not skipping json import test with node 18 --- tests/tests-node/esmock.node.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/tests-node/esmock.node.test.js b/tests/tests-node/esmock.node.test.js index 59a3aa1..d1d673b 100644 --- a/tests/tests-node/esmock.node.test.js +++ b/tests/tests-node/esmock.node.test.js @@ -559,8 +559,8 @@ test('should mock imported json', async () => { } }) - if (/^(18)$/.test(process.versions.node.split('.')[0])) - return assert.ok(true) + // if (/^(18)$/.test(process.versions.node.split('.')[0])) + // return assert.ok(true) assert.strictEqual( Object.keys(importsJSON.JSONobj).sort().join(), 'example,test-example') @@ -578,8 +578,8 @@ test('should mock imported json (strict)', async () => { } }) - if (/^(18)$/.test(process.versions.node.split('.')[0])) - return assert.ok(true) + // if (/^(18)$/.test(process.versions.node.split('.')[0])) + // return assert.ok(true) assert.strictEqual( Object.keys(importsJSON.JSONobj).sort().join(), 'test-example') From 0143813817d7f602d73d00817a26ed850405be20 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 25 Apr 2024 11:41:39 -0700 Subject: [PATCH 12/13] remove un-needed commented-out skip test condition --- tests/tests-node/esmock.node.test.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/tests-node/esmock.node.test.js b/tests/tests-node/esmock.node.test.js index d1d673b..40c59c7 100644 --- a/tests/tests-node/esmock.node.test.js +++ b/tests/tests-node/esmock.node.test.js @@ -559,9 +559,6 @@ test('should mock imported json', async () => { } }) - // if (/^(18)$/.test(process.versions.node.split('.')[0])) - // return assert.ok(true) - assert.strictEqual( Object.keys(importsJSON.JSONobj).sort().join(), 'example,test-example') assert.strictEqual(importsJSON.JSONobj['test-example'], 'test-json-a') @@ -578,9 +575,6 @@ test('should mock imported json (strict)', async () => { } }) - // if (/^(18)$/.test(process.versions.node.split('.')[0])) - // return assert.ok(true) - assert.strictEqual( Object.keys(importsJSON.JSONobj).sort().join(), 'test-example') assert.strictEqual(importsJSON.JSONobj['test-example'], 'test-json-b') From 9dca2fcefdfef2962dc95c542d302624e90772ae Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 25 Apr 2024 11:47:35 -0700 Subject: [PATCH 13/13] remove node 21 from test matrix --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 61a7d62..ceb2e2d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ 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