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

Upgrade deps and restrict to jest >= 25 #19

Merged
merged 5 commits into from
Feb 25, 2020
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
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- image: circleci/node:8
- image: circleci/node:12
working_directory: ~/repo
steps:
- checkout
Expand All @@ -24,4 +24,4 @@ jobs:
command: yarn test
- run:
name: Linter
command: yarn lint
command: yarn lint
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module.exports = {
json: 'always',
},
],
'import/prefer-default-export': ignore
'import/prefer-default-export': ignore,
'no-underscore-dangle': [error, { allow: ['_updateSnapshot'] }],
},
};
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ node_modules
dist
.idea
.jest
*.lock
package-lock.json
package-lock.json
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ node_modules
yarn.lock
npm-shrinkwrap.json
package-lock.json
.jest
.jest
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@
"cacheDirectory": "./.jest/cache"
},
"dependencies": {
"jest-snapshot": "^24.1.0"
"jest-snapshot": "^25.1.0"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.3.3",
"@babel/preset-env": "^7.3.1",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.1.0",
"eslint": "^5.14.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-config-prettier": "^4.0.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jest": "^22.3.0",
"eslint-plugin-json": "^1.4.0",
"eslint-plugin-prettier": "^3.0.1",
"eslint-teamcity": "^2.1.0",
"jest": "^24.1.0",
"jest-cli": "^24.1.0",
"prettier": "^1.16.4"
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.4",
"@babel/preset-env": "^7.8.4",
"babel-eslint": "^10.0.3",
"babel-jest": "^25.1.0",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jest": "^23.8.0",
"eslint-plugin-json": "^2.1.0",
"eslint-plugin-prettier": "^3.1.2",
"eslint-teamcity": "^2.2.0",
"jest": "^25.1.0",
"jest-cli": "^25.1.0",
"prettier": "^1.19.1"
},
"peerDependencies": {
"jest": "*"
"jest": ">= 25.0.0"
}
}
7 changes: 3 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint no-underscore-dangle: ["error", { "allow": ["_updateSnapshot"] }] */
import path from 'path';
import { SnapshotState, toMatchSnapshot, addSerializer } from 'jest-snapshot';

Expand Down Expand Up @@ -32,7 +31,7 @@ afterAll(() => {
});
});

function toMatchSpecificSnapshot(received, snapshotFile, testName) {
function toMatchSpecificSnapshot(received, snapshotFile, ...rest) {
const absoluteSnapshotFile = getAbsolutePathToSnapshot(this.testPath, snapshotFile);

// store the common state to re-use it in "afterAll" hook.
Expand All @@ -47,10 +46,10 @@ function toMatchSpecificSnapshot(received, snapshotFile, testName) {
snapshotsStateMap.set(absoluteSnapshotFile, snapshotState);
}

const newThis = Object.assign({}, this, { snapshotState });
const newThis = { ...this, snapshotState };
const patchedToMatchSnapshot = toMatchSnapshot.bind(newThis);

return patchedToMatchSnapshot(received, testName);
return patchedToMatchSnapshot(received, ...rest);
}

expect.extend({ toMatchSpecificSnapshot });
Expand Down
Loading