Skip to content

Commit

Permalink
Merge pull request #298 from iambumblehead/resolve-test-errors-node-22
Browse files Browse the repository at this point in the history
skip import json test for node 22
  • Loading branch information
iambumblehead authored Apr 25, 2024
2 parents 6134500 + 9dca2fc commit f135cdc
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"plugins": [],
"ignorePatterns": [
"dist",
"importsJSONfile.js"
"importsJSONfile.with.js",
"importsJSONfile.assert.legacy.js"
],
"extends": [
"eslint:recommended",
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions tests/local/importsJSONfile.with.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import JSONobj from './example.json' with { type: 'json' };

export {
JSONobj
}
34 changes: 16 additions & 18 deletions tests/tests-node/esmock.node.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand Down

0 comments on commit f135cdc

Please sign in to comment.