-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #229 from iambumblehead/add-failing-swc-test-folder
add failing swc test folder
- Loading branch information
Showing
9 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"test": ".*.ts$", | ||
"jsc": { | ||
"parser": { | ||
"syntax": "typescript", | ||
"decorators": true | ||
}, | ||
"transform": null | ||
}, | ||
"module": { | ||
"type": "es6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
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 | ||
|
||
test('should mock ts when using node-ts', async () => { | ||
const main = await esmock('../local/main.ts', { | ||
path: { | ||
basename: () => 'hellow' | ||
} | ||
}) | ||
|
||
assert.strictEqual(main.pathbasenamewrap(), 'hellow') | ||
}) | ||
|
||
test('should mock pg', async () => { | ||
const main = await esmock('../local/main.ts', { | ||
'pg': { | ||
Pool: (config:any) => { | ||
return config || 'mocked pool' | ||
} | ||
} | ||
}) | ||
|
||
assert.strictEqual(main.pgpoolwrap(), 'mocked pool') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"type": "module", | ||
"description": "esmock unit tests, tsm with node native runner", | ||
"repository": { | ||
"type": "git", | ||
"url": "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" | ||
}, | ||
"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" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"esm": true, | ||
"compilerOptions": { | ||
"allowSyntheticDefaultImports": true, | ||
"module": "ESNext", | ||
"moduleResolution": "node" | ||
} | ||
} |