diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5575bdd..e250fce 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, 22.1.x] + node-version: [18.x, 20.x, 22.x] os: [ubuntu-latest, windows-latest] steps: - uses: actions/checkout@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 9436ae1..2e5e0ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # changelog + * 2.6.7 _Jul.16.2024_ + * [add swc tests and remove swc caution from README](https://github.com/iambumblehead/esmock/pull/309) thanks @Brooooooklyn + * [unpin node 22.1 at test CI](https://github.com/iambumblehead/esmock/pull/309) and use latest 22.x * 2.6.6 _Jun.15.2024_ * [add tsx tests and remove tsx caution from README](https://github.com/iambumblehead/esmock/pull/305) thanks @galexite * [pin node 22.1 at test CI](https://github.com/iambumblehead/esmock/pull/306) and ignore regressions in new node 22 diff --git a/README.md b/README.md index 757962f..6d92907 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,6 @@ _**Note: For versions of node prior to v20.6.0,** "--loader" command line arguments must be used with `esmock` as demonstrated [in the wiki.][4] Current versions of node do not require "--loader"._ -_**Note: TypeScript loader** `swc-node` is, at time of writing, **incompatible** with other loaders, including esmock._ - `esmock` has the below signature ```js await esmock( diff --git a/package.json b/package.json index eb29438..043ba3f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "esmock", "type": "module", - "version": "2.6.6", + "version": "2.6.7", "license": "ISC", "readmeFilename": "README.md", "description": "provides native ESM import and globals mocking for unit tests", diff --git a/tests/package.json b/tests/package.json index 93f52bd..6bd65bc 100644 --- a/tests/package.json +++ b/tests/package.json @@ -34,6 +34,7 @@ "isnodegt19": "node -e \"+process.versions.node.split('.')[0] > 19 || process.exit(1)\"", "isnodenight": "node -e \"process.versions.node.includes('night') || process.exit(1)\"", "install:esmock": "cd .. && npm install", + "install:test-swc": "cd tests-swc && npm install", "install:test-ava": "cd tests-ava && npm install", "install:test-uvu": "cd tests-uvu && npm install", "install:test-tsm": "cd tests-tsm && npm install", @@ -51,6 +52,7 @@ "test:test-mocha": "cd tests-mocha && npm test", "test:test-ava": "cd tests-ava && npm test", "test:test-tsx": "cd tests-tsx && npm test", + "test:test-swc": "cd tests-swc && npm test", "test:node19-tsm": " cd tests-tsm && npm test", "test:node18-test-tsm": "npm run isnodenight || npm run test:node19-tsm", "test:node18-test-tsx": "cd tests-tsx && npm run test", diff --git a/tests/tests-FAIL-swc/.swcrc b/tests/tests-swc/.swcrc similarity index 100% rename from tests/tests-FAIL-swc/.swcrc rename to tests/tests-swc/.swcrc diff --git a/tests/tests-FAIL-swc/esmock.node-swc.test.ts b/tests/tests-swc/esmock.node-swc.test.ts similarity index 75% rename from tests/tests-FAIL-swc/esmock.node-swc.test.ts rename to tests/tests-swc/esmock.node-swc.test.ts index 2092bb7..fb8149a 100644 --- a/tests/tests-FAIL-swc/esmock.node-swc.test.ts +++ b/tests/tests-swc/esmock.node-swc.test.ts @@ -2,10 +2,7 @@ import test from 'node:test' import assert from 'assert' import esmock from 'esmock' -// ⚠ https://github.com/swc-project/swc-node/issues/710 -// swc tests fail when encountering typescript syntax -// when the typescript sytax are removed, tests pass - +// credit @Brooooooklyn https://github.com/swc-project/swc-node/issues/788 test('should mock js when using swc', async () => { const main = await esmock('../local/main.js', { path: { diff --git a/tests/tests-FAIL-swc/package.json b/tests/tests-swc/package.json similarity index 82% rename from tests/tests-FAIL-swc/package.json rename to tests/tests-swc/package.json index a3ab6ab..e45070a 100644 --- a/tests/tests-FAIL-swc/package.json +++ b/tests/tests-swc/package.json @@ -1,13 +1,15 @@ { "type": "module", - "description": "esmock unit tests, tsm with node native runner", + "description": "esmock unit tests, swc with node native runner", "repository": { "type": "git", "url": "git+https://github.com/iambumblehead/esmock.git" }, "dependencies": { "esmock": "file:..", - "@swc-node/register": "1.9.2" + "typescript": "^5.5.3", + "@swc-node/register": "^1.10.8", + "@swc/core": "^1.6.13" }, "scripts": { "isloaderavailable": "node -e \"(([mj, mn]) => (+mj < 18 || (+mj === 20 && +mn < 6) || (+mj === 18 && +mn < 19)))(process.versions.node.split('.')) || process.exit(1)\"", diff --git a/tests/tests-FAIL-swc/tsconfig.json b/tests/tests-swc/tsconfig.json similarity index 100% rename from tests/tests-FAIL-swc/tsconfig.json rename to tests/tests-swc/tsconfig.json