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

add failing swc test folder #229

Merged
merged 3 commits into from
Aug 15, 2023
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# changelog

* 2.3.7 _Aug.11.2023_
* 2.3.7 _Aug.15.2023_
* [normalize package.json url](https://github.com/iambumblehead/esmock/pull/225) and [reduce loc for loader verification](https://github.com/iambumblehead/esmock/pull/226)
* [small adjustments](https://github.com/iambumblehead/esmock/pull/228) reducing lines of code
* [clerical changes to some](https://github.com/iambumblehead/esmock/pull/229) test folders
* 2.3.6 _Aug.07.2023_
* [resolve global mocking issues](https://github.com/iambumblehead/esmock/pull/224) when using mixed esm cjs import trees
* 2.3.4 _Jul.30.2023_
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ test('mock fetch, Date, setTimeout and any globals', async () => {
})
})

assert.deepEqual(await userCount(), 2)
assert.equal(await userCount(), 2)
})

test('mocks "await import()" using esmock.p', async () => {
Expand Down
13 changes: 13 additions & 0 deletions tests/tests-FAIL-swc/.swcrc
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"
}
}
29 changes: 29 additions & 0 deletions tests/tests-FAIL-swc/esmock.node-swc.test.ts
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')
})
24 changes: 24 additions & 0 deletions tests/tests-FAIL-swc/package.json
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.
8 changes: 8 additions & 0 deletions tests/tests-FAIL-tsx/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"esm": true,
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"module": "ESNext",
"moduleResolution": "node"
}
}