Skip to content

Commit

Permalink
chore: migrate ava to jest (#737)
Browse files Browse the repository at this point in the history
* chore: rename *.mts to *.ts

* chore: migrate ava to jest

* chore: enable pnpm shell-emulator
  • Loading branch information
3846masa authored Jan 14, 2024
1 parent b7e786d commit 4624f94
Show file tree
Hide file tree
Showing 50 changed files with 5,204 additions and 4,477 deletions.
37 changes: 14 additions & 23 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
module.exports = {
overrides: [
{
include: ['**/*.mts'],
presets: [
[
'@babel/preset-env',
{
modules: false,
targets: { node: 14 },
},
],
module.exports = (api) => {
const isTest = api.env('test');

return {
plugins: ['@babel/plugin-proposal-explicit-resource-management'],
presets: [
[
'@babel/preset-env',
{
modules: isTest ? false : 'commonjs',
targets: { node: 18 },
},
],
},
],
presets: [
[
'@babel/preset-env',
{
modules: 'commonjs',
targets: { node: 14 },
},
['@babel/preset-typescript'],
],
['@babel/preset-typescript'],
],
};
};
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
save-exact=true
enable-pre-post-scripts=true
shell-emulator=true
13 changes: 13 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @type {import('jest').Config} */
const config = {
extensionsToTreatAsEsm: ['.ts'],
injectGlobals: false,
roots: ['./src'],
setupFiles: ['./jest/setup.ts'],
testMatch: ['**/__tests__/*.spec.ts'],
transform: {
'\\.+(ts)$': 'babel-jest',
},
};

module.exports = config;
1 change: 1 addition & 0 deletions jest/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'disposablestack/auto';
16 changes: 6 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,7 @@
"lint:prettier": "prettier --check .",
"lint:tsc": "tsc --noEmit",
"semantic-release": "semantic-release",
"pretest": "pnpm run build",
"test": "ava"
},
"ava": {
"files": [
"dist/**/__tests__/*.spec.js",
"dist/**/__tests__/*.spec.mjs"
],
"workerThreads": false
"test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest"
},
"dependencies": {
"agent-base": "^7.1.0"
Expand All @@ -70,9 +62,11 @@
"@3846masa/configs": "github:3846masa/configs#7b80c907f26a993071eafcebea35001608cc627c",
"@babel/cli": "7.23.4",
"@babel/core": "7.23.7",
"@babel/plugin-proposal-explicit-resource-management": "7.23.3",
"@babel/preset-env": "7.23.8",
"@babel/preset-typescript": "7.23.3",
"@hapi/wreck": "18.0.1",
"@jest/globals": "29.7.0",
"@semantic-release/changelog": "6.0.3",
"@semantic-release/git": "10.0.1",
"@types/deasync": "0.1.5",
Expand All @@ -83,11 +77,13 @@
"@types/superagent": "8.1.1",
"@types/tough-cookie": "4.0.5",
"agentkeepalive": "4.5.0",
"ava": "5.3.1",
"axios": "1.6.5",
"babel-jest": "29.7.0",
"deasync": "0.1.29",
"disposablestack": "1.1.2",
"got": "12.6.1",
"http-proxy-agent": "7.0.0",
"jest": "29.7.0",
"needle": "3.3.1",
"node-fetch": "3.3.2",
"phin": "3.7.0",
Expand Down
Loading

0 comments on commit 4624f94

Please sign in to comment.