Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update tests-FAIL-swc to newest swc call pattern. tests still fail #307

Merged
merged 2 commits into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions tests/tests-FAIL-swc/.swcrc
Original file line number Diff line number Diff line change
@@ -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
}
16 changes: 7 additions & 9 deletions tests/tests-FAIL-swc/esmock.node-swc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand All @@ -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')
})
20 changes: 8 additions & 12 deletions tests/tests-FAIL-swc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
}
}
3 changes: 2 additions & 1 deletion tests/tests-FAIL-swc/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"module": "ESNext",
"moduleResolution": "node"
"moduleResolution": "node",
"lib": ["ES2015"]
}
}
Loading