Skip to content

Commit c73e8e5

Browse files
committed
Docs: Document "Storage interface" at QUnit.config.storage
Storing failures and looking them up during rerun, requires only get, set, and remove. But, to clean up unknown past-failures after a success, we also use `key()` and `length` to find any key that matches our naming scheme.
1 parent deccc52 commit c73e8e5

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

docs/api/config/storage.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,47 @@ The Storage object to use for remembering failed tests between runs.
2525

2626
This is used to power the [reorder feature](./reorder.md). In [browser environments](../../browser.md) this will use `sessionStorage` if supported by the browser.
2727

28-
In Node.js and other non-browser environments, there is no storage object available for this purpose by default. You can attach your own preferred form of persistence between test runs, by assigning an object to `QUnit.config.storage` that implements `getItem`, `setItem` and `removeItem` methods, similar to the [Web Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API).
28+
In Node.js and other non-browser environments, there is no storage object available for this purpose by default. You can attach your own preferred form of persistence between test runs, by assigning an object to `QUnit.config.storage` that implements at least the below subset of the [Web Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API).
29+
30+
## Storage interface
31+
32+
```js
33+
storage = {
34+
/**
35+
* @param {string} key
36+
* @param {string} value
37+
*/
38+
setItem (key, value) {
39+
},
40+
41+
/**
42+
* @param {string} key
43+
* @return {string|null}
44+
*/
45+
getItem (key) {
46+
},
47+
48+
/**
49+
* @param {string} key
50+
*/
51+
removeItem (key) {
52+
},
53+
54+
/**
55+
* Get name of key at given offset, e.g. by iterating from 0 to `length`.
56+
*
57+
* @param {number} index
58+
* @return {string|null}
59+
*/
60+
key (index) {
61+
},
62+
63+
/**
64+
* How many keys exist.
65+
*
66+
* @type {number}
67+
*/
68+
get length () {
69+
}
70+
};
71+
```

0 commit comments

Comments
 (0)