Skip to content

Commit 16bc24c

Browse files
authored
Move testing framework over to Jest (#24)
* Starting the new Jest tests * Moving all tests to jest * Updating npm run scripts to use jest instead of individual modules * Upgrading all packages * Adding back codecov which was unintentionally removed
1 parent 77da922 commit 16bc24c

17 files changed

+3671
-1340
lines changed

.eslintrc.js

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
module.exports = {
2-
"extends": [
3-
"airbnb-base",
4-
"prettier"
5-
],
6-
"plugins": [
7-
"prettier"
8-
],
9-
"env": {
10-
"es6": true,
11-
"node": true
2+
extends: ['airbnb-base', 'prettier'],
3+
plugins: ['prettier'],
4+
env: {
5+
es6: true,
6+
node: true
127
},
13-
"rules": {
14-
"prettier/prettier": ["error", { "singleQuote": true }]
8+
rules: {
9+
'prettier/prettier': ['error', { singleQuote: true }]
1510
},
16-
"globals": {
17-
"document": true,
18-
"afterAll": true,
19-
"afterEach": true,
20-
"beforeAll": true,
21-
"beforeEach": true,
22-
"describe": true,
23-
"expect": true,
24-
"it": true
25-
}
11+
globals: {
12+
document: true
13+
},
14+
overrides: [
15+
{
16+
files: ['*.spec.js', '*.jest.js', 'webpack-helpers.js'],
17+
globals: {
18+
jest: true,
19+
afterAll: true,
20+
afterEach: true,
21+
beforeAll: true,
22+
beforeEach: true,
23+
describe: true,
24+
expect: true,
25+
it: true
26+
}
27+
}
28+
]
2629
};

jest.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
displayName: 'CspHtmlWebpackPlugin',
3+
roots: ['<rootDir>'],
4+
testMatch: ['<rootDir>/?(*.)jest.js'],
5+
testPathIgnorePatterns: ['/node_modules/'],
6+
clearMocks: true
7+
};

package-lock.json

Lines changed: 3170 additions & 637 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
"description": "A plugin which, when combined with HTMLWebpackPlugin, adds CSP tags to the HTML output",
55
"main": "plugin.js",
66
"scripts": {
7-
"codecov": "npm run codecov:clean && npm run codecov:generate && npm run codecov:upload",
8-
"codecov:clean": "rm -rf ./coverage",
9-
"codecov:generate": "./node_modules/.bin/istanbul cover ./node_modules/jasmine/bin/jasmine.js spec/plugin.spec.js",
10-
"codecov:upload": "./node_modules/.bin/codecov --token=252086ef-c14d-4f29-ab36-720265249fa2",
117
"eslint": "eslint .",
128
"eslint:fix": "eslint . --fix",
13-
"jasmine": "jasmine ./spec/plugin.spec.js",
14-
"test": "npm run eslint && npm run jasmine && npm run codecov"
9+
"jest": "jest --config=./jest.config.js plugin.jest.js",
10+
"jest:watch": "jest --watch --config=./jest.config.js plugin.jest.js",
11+
"jest:coverage:generate": "jest --coverage --config=./jest.config.js plugin.jest.js",
12+
"jest:coverage:clean": "rm -rf ./coverage",
13+
"jest:coverage:upload": "npx codecov --token=252086ef-c14d-4f29-ab36-720265249fa2",
14+
"jest:coverage": "npm run jest:coverage:clean && npm run jest:coverage:generate && npm run jest:coverage:upload",
15+
"test": "npm run eslint && npm run jest && npm run jest:coverage"
1516
},
1617
"repository": {
1718
"type": "git",
@@ -26,25 +27,25 @@
2627
"author": "Anuj Nair",
2728
"license": "MIT",
2829
"dependencies": {
30+
"babel-jest": "^23.6.0",
2931
"cheerio": "^1.0.0-rc.2",
30-
"lodash": "^4.17.11"
32+
"lodash": "^4.17.11",
33+
"memory-fs": "^0.4.1"
3134
},
3235
"peerDependencies": {
3336
"webpack": "^2 || ^3 || ^4",
3437
"html-webpack-plugin": "^2 || ^3 || ^4"
3538
},
3639
"devDependencies": {
3740
"codecov": "^3.1.0",
38-
"eslint": "^5.6.0",
41+
"eslint": "^5.10.0",
3942
"eslint-config-airbnb-base": "^13.1.0",
40-
"eslint-config-prettier": "^3.0.1",
43+
"eslint-config-prettier": "^3.3.0",
4144
"eslint-plugin-import": "^2.14.0",
42-
"eslint-plugin-prettier": "^2.6.2",
45+
"eslint-plugin-prettier": "^3.0.0",
4346
"html-webpack-plugin": "^3.2.0",
44-
"istanbul": "^0.4.5",
45-
"jasmine": "^3.2.0",
46-
"prettier": "^1.14.3",
47-
"rimraf": "^2.6.2",
48-
"webpack": "^4.19.1"
47+
"jest": "^23.6.0",
48+
"prettier": "^1.15.3",
49+
"webpack": "^4.28.1"
4950
}
5051
}

0 commit comments

Comments
 (0)