Skip to content

Commit

Permalink
Create scripts/run-web-test.sh to remove the * activation point fro…
Browse files Browse the repository at this point in the history
…m `package.json` before running the tests in the web env
  • Loading branch information
whitphx committed Sep 8, 2023
1 parent 0c713d3 commit 9e5f9fb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5110,7 +5110,7 @@
"check:eslint": "eslint src --ext ts",
"pretest": "yarn run test-compile",
"test": "node ./out/test/runTest.js",
"test:web": "vscode-test-web --browserType=chromium --extensionDevelopmentPath=. --extensionTestsPath=dist/web/test/suite/index.js --permission clipboard-read --permission clipboard-write",
"test:web": "./scripts/run-web-test.sh",
"pretest:web": "yarn run compile-web",
"compile-web": "webpack --config ./build/web-extension.webpack.config.js",
"watch-web": "webpack --watch --config ./build/web-extension.webpack.config.js",
Expand Down
25 changes: 25 additions & 0 deletions scripts/run-web-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash -eu
ARGS=$@
ROOT="$(dirname "$(dirname "$(realpath "$0")")")"

# Remove the "*" activation event from package.json
# so that the extension is not activated when running tests.
# Ref: https://github.com/microsoft/vscode-test-web/issues/96#issuecomment-1702658443
setup() {
mv ${ROOT}/package.json ${ROOT}/package.json.bk
jq '.activationEvents |= map(select(. != "*"))' ${ROOT}/package.json.bk > ${ROOT}/package.json
}

tearDown() {
mv ${ROOT}/package.json.bk ${ROOT}/package.json
}

setup
yarn vscode-test-web \
--browserType=chromium \
--extensionDevelopmentPath=. \
--extensionTestsPath=dist/web/test/suite/index.js \
--permission clipboard-read \
--permission clipboard-write \
$ARGS
tearDown

0 comments on commit 9e5f9fb

Please sign in to comment.