diff --git a/tests/tests-FAIL-swc/.swcrc b/tests/tests-FAIL-swc/.swcrc index 50720e11..78a5dc9c 100644 --- a/tests/tests-FAIL-swc/.swcrc +++ b/tests/tests-FAIL-swc/.swcrc @@ -1,13 +1,15 @@ { + "$schema": "https://swc.rs/schema.json", "test": ".*.ts$", "jsc": { "parser": { "syntax": "typescript", - "decorators": true + "importMeta": true }, - "transform": null + "target": "es2022", + "experimental": { + "keepImportAssertions": true + } }, - "module": { - "type": "es6" - } + "isModule": true } diff --git a/tests/tests-FAIL-swc/esmock.node-swc.test.ts b/tests/tests-FAIL-swc/esmock.node-swc.test.ts index 9b739f08..2092bb7e 100644 --- a/tests/tests-FAIL-swc/esmock.node-swc.test.ts +++ b/tests/tests-FAIL-swc/esmock.node-swc.test.ts @@ -6,8 +6,8 @@ import esmock from 'esmock' // swc tests fail when encountering typescript syntax // when the typescript sytax are removed, tests pass -test('should mock ts when using node-ts', async () => { - const main = await esmock('../local/main-ts.ts', { +test('should mock js when using swc', async () => { + const main = await esmock('../local/main.js', { path: { basename: () => 'hellow' } @@ -16,14 +16,12 @@ test('should mock ts when using node-ts', async () => { assert.strictEqual(main.pathbasenamewrap(), 'hellow') }) -test('should mock pg', async () => { +test('should mock ts when using swc', async () => { const main = await esmock('../local/main-ts.ts', { - 'pg': { - Pool: (config:any) => { - return config || 'mocked pool' - } + path: { + basename: () => 'hellow' } }) - assert.strictEqual(main.pgpoolwrap(), 'mocked pool') -}) + assert.strictEqual(main.pathbasenamewrap(), 'hellow') +}) \ No newline at end of file diff --git a/tests/tests-FAIL-swc/package.json b/tests/tests-FAIL-swc/package.json index 29e54851..a3ab6ab0 100644 --- a/tests/tests-FAIL-swc/package.json +++ b/tests/tests-FAIL-swc/package.json @@ -3,22 +3,18 @@ "description": "esmock unit tests, tsm with node native runner", "repository": { "type": "git", - "url": "https://github.com/iambumblehead/esmock.git" + "url": "git+https://github.com/iambumblehead/esmock.git" }, "dependencies": { - "@swc-node/register": "1.6.6", "esmock": "file:..", - "pg": "file:../node_modules/pg", - "sinon": "file:../node_modules/sinon", - "eslint": "file:../node_modules/eslint", - "form-urlencoded": "file:../node_modules/form-urlencoded", - "babelGeneratedDoubleDefault": "file:../local/babelGeneratedDoubleDefault" + "@swc-node/register": "1.9.2" }, "scripts": { - "test:metaresolve": "node --experimental-import-meta-resolve --loader=@swc-node/register/esm --loader=esmock --test esmock.node-swc.test.ts", - "test:nometaresolve": "node --loader=@swc-node/register/esm --loader=esmock --test esmock.node-swc.test.ts", - "test": "npm run test:metaresolve && npm run test:nometaresolve", - "test": "SWCRC=true node --loader=@swc-node/register/esm --loader=esmock --test esmock.node-swc.test.ts", - "note": "⚠ https://github.com/swc-project/swc-node/issues/710" + "isloaderavailable": "node -e \"(([mj, mn]) => (+mj < 18 || (+mj === 20 && +mn < 6) || (+mj === 18 && +mn < 19)))(process.versions.node.split('.')) || process.exit(1)\"", + "test:loader": "echo not-configured", + "test:current": "node --import @swc-node/register/esm-register --test esmock.node-swc.test.ts", + "test": "npm run isloaderavailable && npm run test:loader || npm run test:current", + "note": "⚠ https://github.com/swc-project/swc-node/issues/710", + "status": "swc error: SyntaxError: Unexpected identifier 'MockMap'" } } diff --git a/tests/tests-FAIL-swc/tsconfig.json b/tests/tests-FAIL-swc/tsconfig.json index 5b17f4eb..266f26f0 100644 --- a/tests/tests-FAIL-swc/tsconfig.json +++ b/tests/tests-FAIL-swc/tsconfig.json @@ -3,6 +3,7 @@ "compilerOptions": { "allowSyntheticDefaultImports": true, "module": "ESNext", - "moduleResolution": "node" + "moduleResolution": "node", + "lib": ["ES2015"] } }