Skip to content

Commit e20d59e

Browse files
authored
Move tests and reporting to jest (#216)
* Use node: prefix and update lockfile * Move to jest * Use --forceExit
1 parent 3c3854b commit e20d59e

File tree

7 files changed

+1834
-2668
lines changed

7 files changed

+1834
-2668
lines changed

.github/workflows/tests.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ jobs:
2222
- run: yarn install --network-timeout 1000000 --frozen-lockfile
2323
- run: yarn run build-views
2424
- run: yarn test
25-
- run: yarn run coverage
2625

2726
- name: Upload Coverage
2827
uses: codecov/codecov-action@v3
28+
with:
29+
directory: ./coverage

jest.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
testEnvironment: 'node',
3+
testMatch: ['**/__tests__/**/*.js', '**/?(*.)+(spec|test).js'],
4+
collectCoverage: true,
5+
coverageReporters: ['text', 'lcov'],
6+
coverageDirectory: 'coverage',
7+
coveragePathIgnorePatterns: [
8+
'/node_modules/',
9+
'/test/',
10+
'/coverage/',
11+
'/src/directory.js',
12+
'/src/error.js'
13+
]
14+
};

package.json

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"test": "yarn run test-lint && yarn run test-integration",
88
"test-lint": "zeit-eslint --ext .jsx,.js .",
9-
"test-integration": "nyc --reporter=html --reporter=text ava test/integration.js",
9+
"test-integration": "jest --forceExit test/integration.test.js",
1010
"coverage": "nyc report --reporter=text-lcov > coverage.lcov",
1111
"lint-staged": "git diff --diff-filter=ACMRT --cached --name-only '*.js' '*.jsx' | xargs zeit-eslint",
1212
"build-views": "dottojs -s ./src -d ./src",
@@ -29,29 +29,24 @@
2929
"devDependencies": {
3030
"@zeit/eslint-config-node": "0.2.13",
3131
"@zeit/git-hooks": "0.1.4",
32-
"ava": "2.2.0",
3332
"commander": "2.15.1",
3433
"dot": "1.1.3",
3534
"eslint": "6.1.0",
3635
"fs-extra": "6.0.1",
36+
"jest": "29.7.0",
3737
"micro": "9.3.2",
3838
"node-fetch": "2.6.1",
39-
"nyc": "14.1.1",
4039
"request": "2.87.0",
4140
"sleep-promise": "6.0.0",
4241
"test-listen": "1.1.0"
4342
},
4443
"eslintConfig": {
4544
"extends": [
4645
"@zeit/eslint-config-node"
47-
]
48-
},
49-
"nyc": {
50-
"exclude": [
51-
"src/directory.js",
52-
"src/error.js",
53-
"test/*"
54-
]
46+
],
47+
"env": {
48+
"jest": true
49+
}
5550
},
5651
"eslintIgnore": [
5752
"error.js",
@@ -69,5 +64,6 @@
6964
"path-is-inside": "1.0.2",
7065
"path-to-regexp": "2.2.1",
7166
"range-parser": "1.2.0"
72-
}
67+
},
68+
"packageManager": "[email protected]+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"
7369
}

src/glob-slash.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// This is adopted from https://github.com/scottcorgan/glob-slash/
44

5-
const path = require('path');
5+
const path = require('node:path');
66
const normalize = value => path.posix.normalize(path.posix.join('/', value));
77

88
module.exports = value => (value.charAt(0) === '!' ? `!${normalize(value.substr(1))}` : normalize(value));

src/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Native
2-
const {promisify} = require('util');
3-
const path = require('path');
4-
const {createHash} = require('crypto');
5-
const {realpath, lstat, createReadStream, readdir} = require('fs');
2+
const {promisify} = require('node:util');
3+
const path = require('node:path');
4+
const {createHash} = require('node:crypto');
5+
const {realpath, lstat, createReadStream, readdir} = require('node:fs');
66

77
// Packages
8-
const url = require('url');
8+
const url = require('node:url');
99
const slasher = require('./glob-slash');
1010
const minimatch = require('minimatch');
1111
const pathToRegExp = require('path-to-regexp');

0 commit comments

Comments
 (0)