Skip to content

Commit 9b89bcb

Browse files
web: web tests in github CI (#4431)
Will run the web unit tests in github CI Signed-off-by: nkomonen <[email protected]>
1 parent 2bb2623 commit 9b89bcb

File tree

5 files changed

+44
-4
lines changed

5 files changed

+44
-4
lines changed

.github/workflows/node.js.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,29 @@ jobs:
5353
file: ./coverage/lcov.info
5454
flags: codewhisperer
5555

56+
web:
57+
name: test Web
58+
runs-on: ubuntu-latest
59+
strategy:
60+
fail-fast: true
61+
matrix:
62+
node-version: [16.x]
63+
vscode-version: [stable, insiders]
64+
env:
65+
VSCODE_TEST_VERSION: ${{ matrix.vscode-version }}
66+
NODE_OPTIONS: '--max-old-space-size=8192'
67+
steps:
68+
- uses: actions/checkout@v4
69+
- name: Use Node.js ${{ matrix.node-version }}
70+
uses: actions/setup-node@v4
71+
with:
72+
node-version: ${{ matrix.node-version }}
73+
- run: npm ci
74+
- name: Tests
75+
uses: coactions/setup-xvfb@v1
76+
with:
77+
run: npm run testWeb
78+
5679
windows:
5780
name: test Windows
5881
runs-on: windows-2019

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"compile": "npm run compile -w packages/",
2727
"testCompile": "npm run testCompile -w packages/",
2828
"test": "npm run test -w packages/",
29+
"testWeb": "npm run testWeb -w packages/toolkit",
2930
"testE2E": "npm run testE2E -w packages/",
3031
"testInteg": "npm run testInteg -w packages/",
3132
"package": "npm run package -w packages/toolkit",

packages/toolkit/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4247,11 +4247,13 @@
42474247
"copyFiles": "ts-node ./scripts/build/copyFiles.ts",
42484248
"buildScripts": "npm run generateClients && npm run generatePackage && npm run generateNonCodeFiles && npm run copyFiles",
42494249
"browserWatch": "npm run clean && npm run buildScripts && webpack --config-name web --watch",
4250+
"browserCompile": "npm run clean && npm run buildScripts && webpack --config-name web",
42504251
"browserRun": "npx @vscode/test-web --open-devtools --browserOption=--disable-web-security --waitForDebugger=9222 --extensionDevelopmentPath=. .",
42514252
"compile": "npm run clean && npm run buildScripts && webpack --mode development && npm run copyFiles",
42524253
"watch": "npm run clean && npm run buildScripts && tsc -watch -p ./",
42534254
"testCompile": "npm run buildScripts && tsc -p ./",
42544255
"test": "npm run testCompile && c8 ts-node ./scripts/test/test.ts",
4256+
"testWeb": "npm run browserCompile && c8 ts-node ./scripts/test/testWeb.ts",
42554257
"testE2E": "npm run testCompile && c8 ts-node ./scripts/test/testE2E.ts",
42564258
"testInteg": "npm run testCompile && c8 ts-node ./scripts/test/testInteg.ts",
42574259
"format": "prettier --ignore-path ../../.prettierignore --check src scripts",

packages/toolkit/scripts/test/launchTestUtilities.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const minimum = 'minimum'
1818

1919
const disableWorkspaceTrust = '--disable-workspace-trust'
2020

21-
type SuiteName = 'integration' | 'e2e' | 'unit'
21+
type SuiteName = 'integration' | 'e2e' | 'unit' | 'web'
2222

2323
/**
2424
* This is the generalized method that is used by different test suites (unit, integration, ...) in CI to
@@ -64,7 +64,7 @@ async function getVSCodeCliArgs(params: {
6464
let disableExtensionsArgs: string[] = []
6565
let disableWorkspaceTrustArg: string[] = []
6666

67-
if (params.suite !== 'unit') {
67+
if (params.suite === 'integration' || params.suite === 'e2e') {
6868
disableExtensionsArgs = await getCliArgsToDisableExtensions(params.vsCodeExecutablePath, {
6969
except: [
7070
VSCODE_EXTENSION_ID.python,
@@ -78,16 +78,21 @@ async function getVSCodeCliArgs(params: {
7878
],
7979
})
8080
disableWorkspaceTrustArg = [disableWorkspaceTrust]
81+
} else {
82+
disableExtensionsArgs = ['--disable-extensions']
8183
}
8284

8385
const workspacePath = join(projectRootDir, 'dist', 'src', 'testFixtures', 'workspaceFolder')
86+
// This tells VS Code to run the extension in a web environment, which mimics vscode.dev
87+
const webExtensionKind = params.suite === 'web' ? ['--extensionDevelopmentKind=web'] : []
8488

8589
return {
8690
vscodeExecutablePath: params.vsCodeExecutablePath,
8791
extensionDevelopmentPath: projectRootDir,
92+
8893
extensionTestsPath: resolve(projectRootDir, params.relativeTestEntryPoint),
8994
// For verbose VSCode logs, add "--verbose --log debug". c2165cf48e62c
90-
launchArgs: [...disableExtensionsArgs, workspacePath, ...disableWorkspaceTrustArg],
95+
launchArgs: [...disableExtensionsArgs, workspacePath, ...disableWorkspaceTrustArg, ...webExtensionKind],
9196
extensionTestsEnv: {
9297
['DEVELOPMENT_PATH']: projectRootDir,
9398
['AWS_TOOLKIT_AUTOMATION']: params.suite,
@@ -122,7 +127,7 @@ async function setupVSCodeTestInstance(suite: SuiteName): Promise<string> {
122127
console.log(await invokeVSCodeCli(vsCodeExecutablePath, ['--version']))
123128

124129
// Only certain test suites require specific vscode extensions to be installed
125-
if (suite !== 'unit') {
130+
if (suite === 'e2e' || suite === 'integration') {
126131
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID.python)
127132
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID.yaml)
128133
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID.go)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import { runToolkitTests } from './launchTestUtilities'
7+
void (async () => {
8+
await runToolkitTests('web', 'dist/src/testBrowser/testRunner.js')
9+
})()

0 commit comments

Comments
 (0)