http-snapshotter 0.4.0-beta.2 → 0.4.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/index.js +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ Tip: When you do `SNAPSHOT=update` or `SNAPHOT=append` to create snapshots, run
|
|
|
54
54
|
|
|
55
55
|
Log read/saved snapshots by setting LOG_SNAPSHOT=1 or LOG_SNAPSHOT=summary env variable. It prints the HTTP method, url and snapshot file that it would use. If you want even more details in the logs use LOG_REQ=detailed.
|
|
56
56
|
|
|
57
|
-
Once you are done writing your tests, run your test runner on all your tests and then take a look at `<snapshots directory>/unused-snapshots.log` file to see which snapshot files haven't been used by your final test suite. You can delete unused snapshot files.
|
|
57
|
+
Once you are done writing your tests, run your test runner on all your tests and then take a look at `<snapshots directory>/unused-snapshots.log` file to see which snapshot files haven't been used by your final test suite. You can delete unused snapshot files. You can delete the snapshots with `cd <snapshots directory>; xargs -d '\n' rm -v < unused-snapshots.log`
|
|
58
58
|
|
|
59
59
|
The tests of this library uses this library itself, check the `tests/` directory and try the tests `npm ci; npm test`.
|
|
60
60
|
|
package/index.js
CHANGED
|
@@ -81,7 +81,7 @@ let snapshotDirectory = null;
|
|
|
81
81
|
* @typedef {SnapshotText | SnapshotJson} Snapshot
|
|
82
82
|
*/
|
|
83
83
|
|
|
84
|
-
const dynamodbHostNameRegex = /^dynamodb
|
|
84
|
+
const dynamodbHostNameRegex = /^dynamodb\.(.+)\.amazonaws\.com$/;
|
|
85
85
|
|
|
86
86
|
const defaultKeyDerivationProps = ['method', 'url', 'body'];
|
|
87
87
|
/**
|
|
@@ -91,10 +91,11 @@ async function defaultSnapshotFileNameGenerator(request) {
|
|
|
91
91
|
let filePrefix;
|
|
92
92
|
|
|
93
93
|
const url = new URL(request.url);
|
|
94
|
-
|
|
94
|
+
const matches = url.hostname.match(dynamodbHostNameRegex)
|
|
95
|
+
if (matches) {
|
|
95
96
|
filePrefix = [
|
|
96
97
|
'dynamodb',
|
|
97
|
-
|
|
98
|
+
matches[1], // e.g. eu-west-1
|
|
98
99
|
slugify(request.headers?.get?.('x-amz-target')?.split?.('.')?.pop?.() || ''),
|
|
99
100
|
slugify(JSON.parse(await request.clone().text())?.TableName),
|
|
100
101
|
].filter(Boolean).join('-');
|