-
Notifications
You must be signed in to change notification settings - Fork 684
Commit daf0938
feat(amazonq): package.json npm scripts for build issues with vscode-extension-tester (VET) (#7666)
## Problem
Users running our new E2E UI testing suite have to run a plethora of
commands in order to setup and run our test suite each time their
testing code may change or a new workspace in VSCode is instantiated.
This
[document](https://quip-amazon.com/KfISA389hGty/Setup-Instructions-for-Amazon-Q-VET-UI-Tests)
contains rationale. These commands are exact and can be easy to forget
and small errors in the CLI commands lead to headaches with the setup.
Additionally, we run into a problem when running `npm run package` where
each VSIX installation will have a unique hash and VSCode version
attached to the name, and due to the lack of CLI args for renaming our
VSIX package, we must be able to reference the path to this VSIX
installation on anyones local devices. Notably, many
Vscode-extension-tester (VET) projects use "setup-tests" to attach a
VSCode instance and a Chromedriver instance which is crucial for the
functionality of VET; however, this leads to build issues due to the
inherent nature of VET's "setup-tests" packaging its own VSIX
automatically. In normal circumstances, this would be fine; however, due
to our unique packaging structure of the amazonq directory, we require a
package.ts script to package our directory properly.
## Solution
My solution encompasses adding additional scripts to the package.json
file in the root directory of the aws-toolkit-vscode repository. These
scripts must be run in a specific order in order for them to work
correctly and must **all by run in the root directory.** Namely these
npm scripts are:
```
"test:ui:prepare": "./node_modules/.bin/extest get-vscode -s ~/.vscode-test-resources -n && extest get-chromedriver -s ~/.vscode-test-resources -n",
```
This script essentially does the bulk of the previous "setup-tests", it
installs a local VSCode instance and clears the previous cache and
installs the chromdriver into the VSCode instance. This is stored in a
vscode-test-resources directory in ones local User directory.
```
"test:ui:install": "cd packages/amazonq && npm run package 2>&1 | grep -o 'VSIX Version: [^ ]*' | cut -d' ' -f3 | xargs -I{} bash -c 'cd ../../ && ./node_modules/.bin/extest install-vsix -f amazon-q-vscode-{}.vsix -e packages/amazonq/test/e2e/amazonq/resources -s ~/.vscode-test-resources'",
```
This script installs our VSIX by going into the amazonq package and
running our npm run package. This eliminates the need for any additional
scripts by allowing for a CLI/RegEx command to be utilized to find the
specific hash of the VSIX in our terminal output and input it within the
install-vsix command for extest.
```
"test:ui:run": "npm run testCompile && ./node_modules/.bin/extest run-tests -s ~/.vscode-test-resources -e packages/amazonq/test/e2e/amazonq/resources packages/amazonq/dist/test/e2e/amazonq/VET.test.js",
```
This script runs our VET.test.js script and does the testCompile npm
script that has already been built into the repo. This is because when
we run "npm run package", our compiled tests within the dist directory
are deleted. We must run testCompile after this command in order to
properly compile our tests.
```
"test:ui": "npm run test:ui:prepare && npm run test:ui:install && npm run test:ui:run",
```
This script combines all of our scripts into a chronological order.
---
- Treat all work as PUBLIC. Private `feature/x` branches will not be
squash-merged at release time.
- Your code changes must meet the guidelines in
[CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
---------
Co-authored-by: laura-codess <[email protected]>1 parent 687427c commit daf0938Copy full SHA for daf0938
File tree
Expand file treeCollapse file tree
2 files changed
+364
-1388
lines changedFilter options
Expand file treeCollapse file tree
2 files changed
+364
-1388
lines changed
0 commit comments