Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: document session handling pattern
- Loading branch information
Igor Muchychka
committed
Nov 16, 2017
1 parent
d2cd6fe
commit 6ad6a2d
Showing
3 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
## Session handling | ||
|
||
If you test a site which uses cookies, localStorage or sessionStorage its a good practise to clear them after each test case. | ||
Not doing so will make the test cases not isolated. | ||
Which can lead to not reliable, failing test where would be very hard to find the root cause of the issue. | ||
Creating a new webdriver session for every test case is not necessary. | ||
A proper cleanup and page refresh should be sufficient in most cases. | ||
As starter you can use the following support code. | ||
|
||
```javascript | ||
const { client } = require('nightwatch-cucumber'); | ||
const { defineSupportCode } = require('cucumber'); | ||
|
||
defineSupportCode(({ After }) => { | ||
After(() => client.execute(` | ||
localStorage.clear(); | ||
sessionStorage.clear(); | ||
`).deleteCookies().refresh()); | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,7 @@ code { | |
pre code { | ||
font-size: inherit; | ||
color: inherit; | ||
padding: 0; | ||
} | ||
|
||
@media (max-width: 769px) { | ||
|