Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Taiko plugin for local and session storage.
- Loading branch information
BugDiver
committed
Sep 9, 2019
0 parents
commit faceae3
Showing
11 changed files
with
5,461 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"env": { | ||
"es6": true, | ||
"node": true, | ||
"browser": true, | ||
"mocha": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"parserOptions": { | ||
"sourceType": "module", | ||
"ecmaVersion": 8 | ||
}, | ||
"rules": { | ||
"indent": [ | ||
"error", | ||
4 | ||
], | ||
"linebreak-style": [ | ||
"error", | ||
"unix" | ||
], | ||
"quotes": [ | ||
"error", | ||
"single" | ||
], | ||
"no-constant-condition": [ | ||
"error", | ||
{ | ||
"checkLoops": false | ||
} | ||
], | ||
"no-empty": [ | ||
"error", | ||
{ | ||
"allowEmptyCatch": true | ||
} | ||
], | ||
"semi": [ | ||
"error", | ||
"always" | ||
], | ||
"no-console": 0 | ||
} | ||
} |
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,10 @@ | ||
.DS_Store | ||
node_modules/ | ||
dist/ | ||
lib/ | ||
coverage/ | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
deploy/ | ||
artifacts/ |
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,13 @@ | ||
docs/* | ||
tests/* | ||
build/* | ||
.local-chromium | ||
.eslintrc | ||
.vscode | ||
.github | ||
test | ||
.vscode | ||
jest* | ||
TODO* | ||
azure* | ||
docs |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Vinay Shankar Shukla. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,117 @@ | ||
<h1 align="center"> | ||
<br> | ||
<img src="./assets/taiko-storage.png" alt="Taiko Storage"> | ||
<br> | ||
<br> | ||
<br> | ||
</h1> | ||
|
||
|
||
# taiko-storage | ||
|
||
A taiko plugin to interact with browser storages (local and session). | ||
|
||
## Installation | ||
|
||
- `npm install taiko-storage --save` | ||
|
||
## Usage | ||
|
||
```javascript | ||
const { openBrowser, closeBrowser, click, storage: {local, session} } = require('taiko'); | ||
|
||
(async () => { | ||
try { | ||
await openBrowser(); | ||
await local.setItem("Key", "Value"); | ||
let value = await local.getItem("Key"); | ||
// more actions | ||
// ... | ||
} finally { | ||
await closeBrowser(); | ||
} | ||
})(); | ||
``` | ||
|
||
## APIs | ||
|
||
The plugin exposes two variables `local` and `session` which represents to the respective storages. | ||
The APIs for both the storage are same and try to very close the the native storage apis. | ||
|
||
### `setItem(key, value)` Command | ||
|
||
set the given key value to storage | ||
|
||
```js | ||
await local.setItem(key, value); | ||
// or | ||
await session.setItem(key, value); | ||
|
||
``` | ||
|
||
###### `getItem(key)` Command | ||
|
||
featch the value for given key from storage | ||
|
||
```js | ||
await local.getItem(key); | ||
// or | ||
await session.getItem(key); | ||
|
||
``` | ||
|
||
|
||
###### `hasItem(key)` Command | ||
|
||
validate if the given key exists in storage. | ||
|
||
```js | ||
await local.hasItem(key); | ||
// or | ||
await session.hasItem(key); | ||
|
||
``` | ||
|
||
|
||
###### `removeItem(key)` Command | ||
|
||
remove the item with given key from the storage. | ||
|
||
```js | ||
await local.removeItem(key); | ||
// or | ||
await session.removeItem(key); | ||
|
||
``` | ||
|
||
|
||
###### `clear()` Command | ||
|
||
clear the stoarage | ||
|
||
```js | ||
await local.clear(); | ||
// or | ||
await session.clear(); | ||
|
||
``` | ||
|
||
###### `length()` Command | ||
|
||
tell the no of items in storage. | ||
|
||
```js | ||
await local.length(); | ||
// or | ||
await session.length(); | ||
|
||
``` | ||
|
||
## Use in Taiko REPL | ||
|
||
To launch the REPL type `taiko --plugin taiko-storage` in your favorite terminal application. This will launch the Taiko Prompt. | ||
|
||
e.g | ||
`Version: 0.7.0 (Chromium:74.0.3723.0) Type .api for help and .exit to quit` | ||
|
||
You should now have full access to local and session storage apis in the taiko REPL window |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.