From 9bd9eaac9adec3d8442fd85eac32a6f640de16e1 Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 10 Jul 2023 21:55:53 -0700 Subject: [PATCH 1/6] try resolve tsx failing test --- tests/tests-ava-tsx/esmock.ava.tsx.test.ts | 2 +- tests/tests-ava-tsx/package.json | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/tests/tests-ava-tsx/esmock.ava.tsx.test.ts b/tests/tests-ava-tsx/esmock.ava.tsx.test.ts index 1cd5fe09..8b2ae907 100644 --- a/tests/tests-ava-tsx/esmock.ava.tsx.test.ts +++ b/tests/tests-ava-tsx/esmock.ava.tsx.test.ts @@ -11,7 +11,7 @@ test('should mock js when using tsx', async t => { t.is(main.pathbasenamewrap(), 'hellow') }) -test.failing('should mock ts when using tsx - unknown file extension', async t => { +test.only('should mock ts when using tsx - unknown file extension', async t => { const main = await esmock('../local/main.ts', { path: { basename: () => 'hellow' diff --git a/tests/tests-ava-tsx/package.json b/tests/tests-ava-tsx/package.json index 65a7a7a3..a2f5ce23 100644 --- a/tests/tests-ava-tsx/package.json +++ b/tests/tests-ava-tsx/package.json @@ -8,22 +8,15 @@ "dependencies": { "ava": "^5.3.1", "babelGeneratedDoubleDefault": "file:../local/babelGeneratedDoubleDefault", - "eslint": "file:../node_modules/eslint", "esmock": "file:..", - "form-urlencoded": "file:../node_modules/form-urlencoded", - "sinon": "file:../node_modules/sinon", "tsx": "^3.12.7" }, "scripts": { - "test": "ava" + "test": "NODE_OPTIONS='--experimental-specifier-resolution=node --loader=tsx --loader=esmock' ava" }, "ava": { "extensions": { "ts": "module" - }, - "nodeArguments": [ - "--loader=tsx", - "--loader=esmock" - ] + } } } From cb87503ed0cb2d26f3f3e893fc7e876f75701716 Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 10 Jul 2023 21:59:26 -0700 Subject: [PATCH 2/6] remove un-needed dependency --- tests/tests-ava-tsx/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/tests-ava-tsx/package.json b/tests/tests-ava-tsx/package.json index a2f5ce23..f1d43abe 100644 --- a/tests/tests-ava-tsx/package.json +++ b/tests/tests-ava-tsx/package.json @@ -7,7 +7,6 @@ }, "dependencies": { "ava": "^5.3.1", - "babelGeneratedDoubleDefault": "file:../local/babelGeneratedDoubleDefault", "esmock": "file:..", "tsx": "^3.12.7" }, From bb17cb484f873f2e72c56e3f4d0fa372dfb7778e Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 10 Jul 2023 22:54:31 -0700 Subject: [PATCH 3/6] changes to make switching test-runner or transpiler easier --- tests/tests-ava-tsx/esmock.ava.tsx.test.ts | 20 ++++++-------------- tests/tests-ava-tsx/package.json | 10 ++++++++-- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/tests/tests-ava-tsx/esmock.ava.tsx.test.ts b/tests/tests-ava-tsx/esmock.ava.tsx.test.ts index 8b2ae907..0ac46e74 100644 --- a/tests/tests-ava-tsx/esmock.ava.tsx.test.ts +++ b/tests/tests-ava-tsx/esmock.ava.tsx.test.ts @@ -1,32 +1,24 @@ +// import test from 'node:test' import test from 'ava' +import assert from 'assert' import esmock from 'esmock' -test('should mock js when using tsx', async t => { +test('should mock js when using tsx', async () => { const main = await esmock('../local/main.js', { path: { basename: () => 'hellow' } }) - t.is(main.pathbasenamewrap(), 'hellow') + assert.strictEqual(main.pathbasenamewrap(), 'hellow') }) -test.only('should mock ts when using tsx - unknown file extension', async t => { +test('should mock ts when using tsx - unknown file extension', async () => { const main = await esmock('../local/main.ts', { path: { basename: () => 'hellow' } }) - t.is(main.pathbasenamewrap(), 'hellow') -}) - -test.failing('should mock ts when using tsx - invalid moduleId', async t => { - const main = await esmock('../local/mainUnique.js', { - path: { - basename: () => 'hellow' - } - }) - - t.is(main.pathbasenamewrap(), 'hellow') + assert.strictEqual(main.pathbasenamewrap(), 'hellow') }) diff --git a/tests/tests-ava-tsx/package.json b/tests/tests-ava-tsx/package.json index f1d43abe..196132f1 100644 --- a/tests/tests-ava-tsx/package.json +++ b/tests/tests-ava-tsx/package.json @@ -8,12 +8,18 @@ "dependencies": { "ava": "^5.3.1", "esmock": "file:..", - "tsx": "^3.12.7" + "tsx": "^3.12.7", + "ts-node": "^10.9.1" }, "scripts": { - "test": "NODE_OPTIONS='--experimental-specifier-resolution=node --loader=tsx --loader=esmock' ava" + "test-node-ts-node": "node --loader=ts-node/esm --loader=esmock --test esmock.ava.tsx.test.ts", + "test-ava-ts-node": "NODE_OPTIONS='--loader=ts-node/esm --loader=esmock' ava *test.ts", + "test-node-tsx": "node --loader=tsx --loader=esmock --test esmock.ava.tsx.test.ts", + "test-ava-tsx": "NODE_OPTIONS='--loader=tsx --loader=esmock' ava *test.ts", + "test": "npm run test-ava-ts-node" }, "ava": { + "failWithoutAssertions": false, "extensions": { "ts": "module" } From dbd475af50b5cf254e8e2a8a771aeff533a1ea8f Mon Sep 17 00:00:00 2001 From: chris Date: Fri, 28 Jul 2023 10:02:40 -0700 Subject: [PATCH 4/6] mv tests-ava-tsx tests-tsx --- tests/tests-ava-tsx/package.json | 27 ------------------- .../esmock.node.tsx.test.ts} | 3 +-- tests/tests-tsx/package.json | 15 +++++++++++ .../tsconfig.json | 0 4 files changed, 16 insertions(+), 29 deletions(-) delete mode 100644 tests/tests-ava-tsx/package.json rename tests/{tests-ava-tsx/esmock.ava.tsx.test.ts => tests-tsx/esmock.node.tsx.test.ts} (90%) create mode 100644 tests/tests-tsx/package.json rename tests/{tests-ava-tsx => tests-tsx}/tsconfig.json (100%) diff --git a/tests/tests-ava-tsx/package.json b/tests/tests-ava-tsx/package.json deleted file mode 100644 index 196132f1..00000000 --- a/tests/tests-ava-tsx/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "type": "module", - "description": "esmock unit tests, tsx with ava", - "repository": { - "type": "git", - "url": "https://github.com/iambumblehead/esmock.git" - }, - "dependencies": { - "ava": "^5.3.1", - "esmock": "file:..", - "tsx": "^3.12.7", - "ts-node": "^10.9.1" - }, - "scripts": { - "test-node-ts-node": "node --loader=ts-node/esm --loader=esmock --test esmock.ava.tsx.test.ts", - "test-ava-ts-node": "NODE_OPTIONS='--loader=ts-node/esm --loader=esmock' ava *test.ts", - "test-node-tsx": "node --loader=tsx --loader=esmock --test esmock.ava.tsx.test.ts", - "test-ava-tsx": "NODE_OPTIONS='--loader=tsx --loader=esmock' ava *test.ts", - "test": "npm run test-ava-ts-node" - }, - "ava": { - "failWithoutAssertions": false, - "extensions": { - "ts": "module" - } - } -} diff --git a/tests/tests-ava-tsx/esmock.ava.tsx.test.ts b/tests/tests-tsx/esmock.node.tsx.test.ts similarity index 90% rename from tests/tests-ava-tsx/esmock.ava.tsx.test.ts rename to tests/tests-tsx/esmock.node.tsx.test.ts index 0ac46e74..063bb0f3 100644 --- a/tests/tests-ava-tsx/esmock.ava.tsx.test.ts +++ b/tests/tests-tsx/esmock.node.tsx.test.ts @@ -1,5 +1,4 @@ -// import test from 'node:test' -import test from 'ava' +import test from 'node:test' import assert from 'assert' import esmock from 'esmock' diff --git a/tests/tests-tsx/package.json b/tests/tests-tsx/package.json new file mode 100644 index 00000000..3cdf8955 --- /dev/null +++ b/tests/tests-tsx/package.json @@ -0,0 +1,15 @@ +{ + "type": "module", + "description": "esmock unit tests, tsx with node", + "repository": { + "type": "git", + "url": "https://github.com/iambumblehead/esmock.git" + }, + "dependencies": { + "esmock": "file:..", + "tsx": "^3.12.7" + }, + "scripts": { + "test": "node --loader=tsx --loader=esmock --test esmock.ava.tsx.test.ts" + } +} diff --git a/tests/tests-ava-tsx/tsconfig.json b/tests/tests-tsx/tsconfig.json similarity index 100% rename from tests/tests-ava-tsx/tsconfig.json rename to tests/tests-tsx/tsconfig.json From f59f7254e0a26c820850730a16415966b443ddb8 Mon Sep 17 00:00:00 2001 From: chris Date: Fri, 28 Jul 2023 10:10:19 -0700 Subject: [PATCH 5/6] added note about tsx to README --- CHANGELOG.md | 1 + README.md | 3 ++- tests/tests-tsx/esmock.node.tsx.test.ts | 20 +++++++++++--------- tests/tests-tsx/package.json | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7be35f53..978041e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * 2.3.3 _Jul.27.2023_ * [do not error when processing node hashbang](https://github.com/iambumblehead/esmock/pull/217) scripts from @tommy-mitchell + * [add note explaining](https://github.com/iambumblehead/esmock/pull/211) why tsx [does not work](https://github.com/esbuild-kit/tsx/issues/264) * 2.3.2 _Jul.22.2023_ * [restore ava unit-test](https://github.com/iambumblehead/esmock/pull/213) process at node20 test pipeline * [investigate problems](https://github.com/iambumblehead/esmock/issues/209) using tsx from @tommy-mitchell diff --git a/README.md b/README.md index 513b6c29..3307c6db 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,8 @@ "test-uvu": "NODE_OPTIONS=--loader=esmock uvu spec", "test-tsm": "node --loader=tsm --loader=esmock --test *ts", "test-ts": "node --loader=ts-node/esm --loader=esmock --test *ts", - "test-jest": "NODE_OPTIONS=--loader=esmock jest" + "test-jest": "NODE_OPTIONS=--loader=esmock jest", + "test-tsx": "⚠ https://github.com/esbuild-kit/tsx/issues/264" }, "jest": { "runner": "jest-light-runner" diff --git a/tests/tests-tsx/esmock.node.tsx.test.ts b/tests/tests-tsx/esmock.node.tsx.test.ts index 063bb0f3..3211030f 100644 --- a/tests/tests-tsx/esmock.node.tsx.test.ts +++ b/tests/tests-tsx/esmock.node.tsx.test.ts @@ -12,12 +12,14 @@ test('should mock js when using tsx', async () => { assert.strictEqual(main.pathbasenamewrap(), 'hellow') }) -test('should mock ts when using tsx - unknown file extension', async () => { - const main = await esmock('../local/main.ts', { - path: { - basename: () => 'hellow' - } - }) - - assert.strictEqual(main.pathbasenamewrap(), 'hellow') -}) +// tsx fails :/ https://github.com/esbuild-kit/tsx/issues/264 +// +// test('should mock ts when using tsx - unknown file extension', async () => { +// const main = await esmock('../local/main.ts', { +// path: { +// basename: () => 'hellow' +// } +// }) +// +// assert.strictEqual(main.pathbasenamewrap(), 'hellow') +// }) diff --git a/tests/tests-tsx/package.json b/tests/tests-tsx/package.json index 3cdf8955..80ab97dd 100644 --- a/tests/tests-tsx/package.json +++ b/tests/tests-tsx/package.json @@ -10,6 +10,6 @@ "tsx": "^3.12.7" }, "scripts": { - "test": "node --loader=tsx --loader=esmock --test esmock.ava.tsx.test.ts" + "test": "node --loader=tsx --loader=esmock --test esmock.node.tsx.test.ts" } } From f7019cdb17cebce2a8a7c33999bacb22db781ebd Mon Sep 17 00:00:00 2001 From: chris Date: Fri, 28 Jul 2023 10:12:56 -0700 Subject: [PATCH 6/6] add note about pinned node 18.6 version to ci tests --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 978041e0..569a5e2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,9 @@ # changelog - * 2.3.3 _Jul.27.2023_ + * 2.3.3 _Jul.28.2023_ * [do not error when processing node hashbang](https://github.com/iambumblehead/esmock/pull/217) scripts from @tommy-mitchell * [add note explaining](https://github.com/iambumblehead/esmock/pull/211) why tsx [does not work](https://github.com/esbuild-kit/tsx/issues/264) + * [pin node 18.16.x](https://github.com/iambumblehead/esmock/pull/217) to ci test matrix, re node [!48948](https://github.com/nodejs/node/issues/48948) * 2.3.2 _Jul.22.2023_ * [restore ava unit-test](https://github.com/iambumblehead/esmock/pull/213) process at node20 test pipeline * [investigate problems](https://github.com/iambumblehead/esmock/issues/209) using tsx from @tommy-mitchell