Skip to content

Commit 65b7453

Browse files
authored
Merge pull request #10 from javierbrea/v1.1.0
V1.1.0
2 parents 9eee21e + d344f14 commit 65b7453

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+15971
-18
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
# tests
1010
/coverage
11+
/test-acceptance/app/build
12+
/test-acceptance/app/node_modules
13+
/test-acceptance/app/cypress/screenshots
14+
/test-acceptance/app/cypress/fixtures
1115

1216
# misc
1317
.DS_Store

.travis.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
language: node_js
22

33
node_js:
4-
- "10"
4+
- 10.8
55

66
cache:
77
directories:
8-
- "node_modules"
9-
- "$HOME/.sonar/cache"
8+
- ~/.npm
9+
- ~/.cache
10+
- node_modules
11+
- test-acceptance/app/node_modules
12+
- ~/.sonar/cache
1013

1114
addons:
15+
apt:
16+
packages:
17+
- libgconf-2-4
1218
sonarcloud:
1319
organization: "javierbrea"
1420
token:
@@ -19,6 +25,12 @@ addons:
1925
script:
2026
- npm run lint
2127
- npm run test
28+
- cd test-acceptance/app
29+
- npm ci
30+
- npm run cypress:install
31+
- npm run cypress:verify
32+
- npm run test:ci
33+
- cd ../..
2234
- npm run coveralls
2335
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sonar-scanner; fi'
2436

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111
### Removed
1212
### BREAKING CHANGES
1313

14+
## [1.1.0] - 2019-10-27
15+
### Added
16+
- Add getLocalStorage command
17+
- Add setLocalStorage command
18+
- Add removeLocalStorage command
19+
- Add acceptance tests
20+
21+
### Changed
22+
- Improve documentation
23+
1424
## [1.0.0] - 2019-10-26
1525
### Added
1626
- Add saveLocalStorage command

README.md

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,65 @@ npm i --save-dev cypress-localstorage-commands
3131
Add this line to your project's `cypress/support/commands.js`:
3232

3333
```js
34-
import 'cypress-localstorage-commands'
34+
import "cypress-localstorage-commands"
3535
```
3636

3737
You can now use all next commands:
3838

39+
### Commands
40+
41+
Save current localStorage values into an internal "snapshot":
42+
43+
```js
44+
cy.saveLocalStorage();
45+
```
46+
47+
Restore localStorage to previously "snapshot" saved values:
48+
3949
```js
40-
cy.saveLocalStorage() // Save current localStorage values into an internal "snapshot"
50+
cy.restoreLocalStorage();
4151
```
4252

53+
Clear localStorage "snapshot" values:
54+
55+
```js
56+
cy.clearLocalStorageSnapshot();
57+
```
58+
59+
Get localStorage item. Equivalent to `localStorage.getItem` in browser:
60+
4361
```js
44-
cy.restoreLocalStorage() // Restore localStorage to previously "snapshot" saved values
62+
cy.getLocalStorage("item");
4563
```
4664

65+
Set localStorage item. Equivalent to `localStorage.setItem` in browser:
66+
67+
```js
68+
cy.setLocalStorage("item", "value");
69+
```
70+
71+
Remove localStorage item. Equivalent to `localStorage.removeItem` in browser:
72+
73+
```js
74+
cy.removeLocalStorage("item");
75+
```
76+
77+
### Preserving local storage between tests
78+
79+
Use `saveLocalStorage` to save a snapshot of current `localStorage` at the end of one test, and use the `restoreLocalStorage` command to restore it at the beginning of another one:
80+
4781
```js
48-
cy.clearLocalStorageSnapshot() // Clear localStorage "snapshot" values
82+
it("should hide privacy policy message on click accept cookies button", () => {
83+
cy.get("#accept-cookies").click();
84+
cy.get("#privacy-policy").should("not.be.visible");
85+
cy.saveLocalStorage();
86+
});
87+
88+
it("should not show privacy policy message after reloading page", () => {
89+
cy.restoreLocalStorage();
90+
cy.reload();
91+
cy.get("#privacy-policy").should("not.be.visible");
92+
});
4993
```
5094

5195
## Contributing

package-lock.json

Lines changed: 122 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cypress-localstorage-commands",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "Extends Cypress' cy commands with localStorage methods. Allows preserving localStorage between tests",
55
"keywords": [
66
"cypress",
@@ -22,16 +22,18 @@
2222
"main": "index.js",
2323
"scripts": {
2424
"coveralls": "cat ./coverage/lcov.info | coveralls",
25-
"lint": "eslint src test",
25+
"lint": "eslint src test test-acceptance/app/src test-acceptance/app/cypress",
2626
"lint-staged": "lint-staged",
2727
"test": "jest"
2828
},
2929
"dependencies": {},
3030
"devDependencies": {
31+
"babel-eslint": "^10.0.3",
3132
"coveralls": "^3.0.7",
3233
"eslint": "6.6.0",
3334
"eslint-config-prettier": "^6.4.0",
3435
"eslint-plugin-prettier": "^3.1.1",
36+
"eslint-plugin-react": "^7.16.0",
3537
"husky": "^3.0.9",
3638
"jest": "^24.9.0",
3739
"lint-staged": "^9.4.2",
@@ -43,7 +45,9 @@
4345
},
4446
"lint-staged": {
4547
"src/**/*.js": "eslint",
46-
"test/**/*.js": "eslint"
48+
"test/**/*.js": "eslint",
49+
"test-acceptance/app/src/**/*.js": "eslint",
50+
"test-acceptance/app/cypress/**/*.js": "eslint"
4751
},
4852
"husky": {
4953
"hooks": {

sonar-project.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
sonar.organization=javierbrea
22
sonar.projectKey=cypress-localstorage-commands
3-
sonar.projectVersion=1.0.0
3+
sonar.projectVersion=1.1.0
44

55
sonar.javascript.file.suffixes=.js
66
sonar.sourceEncoding=UTF-8
7-
sonar.exclusions=node_modules/**
8-
sonar.coverage.exclusions=test/**/*,index.js,jest.config.js
7+
sonar.exclusions=node_modules/**,test-acceptance/app/node_modules/**
8+
sonar.coverage.exclusions=test/**/*,index.js,jest.config.js,test-acceptance/**/*
99
sonar.javascript.lcov.reportPaths=coverage/lcov.info
1010
sonar.host.url=https://sonarcloud.io
1111

1212
sonar.issue.ignore.multicriteria=j1
1313
sonar.issue.ignore.multicriteria.j1.ruleKey=javascript:S4144
14-
sonar.issue.ignore.multicriteria.j1.resourceKey=test/**/*
14+
sonar.issue.ignore.multicriteria.j1.resourceKey=test/**/*,test-acceptance/**/*

0 commit comments

Comments
 (0)