Skip to content

Commit 3540b80

Browse files
committed
feat: add patch script to /test
1 parent 9871001 commit 3540b80

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

test/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"#": "We must put jest in a sub-directory otherwise VS Code somehow picks up the types and generates conflicts with mocha.",
3+
"scripts": {
4+
"postinstall": "./scripts/patch.sh"
5+
},
36
"devDependencies": {
47
"@types/jest": "^26.0.20",
58
"@types/jsdom": "^16.2.6",

test/scripts/patch.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
apply_service_worker_mock_patches() {
5+
# The `service-worker-mock` package is no longer maintained
6+
# so we have to apply patches ourselves
7+
8+
# This patch fixes an undefined error in fetch.js and adds a missing import
9+
patch --forward node_modules/service-worker-mock/fetch.js < patches/service-worker-mock-fetch.patch
10+
11+
# This patch adds a missing import
12+
patch --forward node_modules/service-worker-mock/models/Response.js < patches/service-worker-mock-response.patch
13+
}
14+
15+
main() {
16+
echo -e "🔨 Applying patches..."
17+
apply_service_worker_mock_patches
18+
19+
echo -e "✅ Patches applied successfully."
20+
}
21+
22+
main "$@"

0 commit comments

Comments
 (0)