Skip to content

Commit

Permalink
Merge pull request #210 from tommy-mitchell/tests-ava-tsx
Browse files Browse the repository at this point in the history
Add failing tests for AVA with tsx
  • Loading branch information
iambumblehead authored Jul 10, 2023
2 parents a7615f7 + d9c0e7d commit 2850cea
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/local/mainUnique.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import path from 'path'
import pg from 'pg'

export default {
pathbasenamewrap: (n: any) => path.basename(n),
pgpoolwrap: (n: any) => pg.Pool(n)
}
32 changes: 32 additions & 0 deletions tests/tests-ava-tsx/esmock.ava.tsx.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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')
})
29 changes: 29 additions & 0 deletions tests/tests-ava-tsx/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"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"
]
}
}
8 changes: 8 additions & 0 deletions tests/tests-ava-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"
}
}

0 comments on commit 2850cea

Please sign in to comment.