diff --git a/CHANGELOG.md b/CHANGELOG.md index 7be35f53..569a5e2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +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 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-ava-tsx/esmock.ava.tsx.test.ts b/tests/tests-ava-tsx/esmock.ava.tsx.test.ts deleted file mode 100644 index 1cd5fe09..00000000 --- a/tests/tests-ava-tsx/esmock.ava.tsx.test.ts +++ /dev/null @@ -1,32 +0,0 @@ -import test from 'ava' -import esmock from 'esmock' - -test('should mock js when using tsx', async t => { - const main = await esmock('../local/main.js', { - path: { - basename: () => 'hellow' - } - }) - - t.is(main.pathbasenamewrap(), 'hellow') -}) - -test.failing('should mock ts when using tsx - unknown file extension', async t => { - 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') -}) diff --git a/tests/tests-ava-tsx/package.json b/tests/tests-ava-tsx/package.json deleted file mode 100644 index 65a7a7a3..00000000 --- a/tests/tests-ava-tsx/package.json +++ /dev/null @@ -1,29 +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", - "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" - }, - "ava": { - "extensions": { - "ts": "module" - }, - "nodeArguments": [ - "--loader=tsx", - "--loader=esmock" - ] - } -} diff --git a/tests/tests-tsx/esmock.node.tsx.test.ts b/tests/tests-tsx/esmock.node.tsx.test.ts new file mode 100644 index 00000000..3211030f --- /dev/null +++ b/tests/tests-tsx/esmock.node.tsx.test.ts @@ -0,0 +1,25 @@ +import test from 'node:test' +import assert from 'assert' +import esmock from 'esmock' + +test('should mock js when using tsx', async () => { + const main = await esmock('../local/main.js', { + 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 new file mode 100644 index 00000000..80ab97dd --- /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.node.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