Skip to content

Commit 7e3cd3d

Browse files
committed
consolidate test scripts
1 parent e1a8f08 commit 7e3cd3d

File tree

9 files changed

+67
-67
lines changed

9 files changed

+67
-67
lines changed

packages/amazonq/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
"lint": "true",
5858
"watch": "npm run clean && npm run buildScripts && tsc -watch -p ./",
5959
"testCompile": "npm run clean && npm run buildScripts && npm run compileOnly",
60-
"test": "npm run testCompile && c8 --allowExternal ts-node ../core/scripts/test/test.ts dist/test/unit/index.js ../core/dist/src/testFixtures/workspaceFolder",
61-
"testE2E": "npm run testCompile && c8 --allowExternal ts-node ../core/scripts/test/testE2E.ts dist/test/e2e/index.js ../core/dist/src/testFixtures/workspaceFolder",
60+
"test": "npm run testCompile && c8 --allowExternal ts-node ../core/scripts/test/launchTest.ts unit dist/test/unit/index.js ../core/dist/src/testFixtures/workspaceFolder",
61+
"testE2E": "npm run testCompile && c8 --allowExternal ts-node ../core/scripts/test/launchTest.ts e2e dist/test/e2e/index.js ../core/dist/src/testFixtures/workspaceFolder",
6262
"webRun": "npx @vscode/test-web --open-devtools --browserOption=--disable-web-security --waitForDebugger=9222 --extensionDevelopmentPath=. .",
6363
"webWatch": "npm run clean && npm run buildScripts && webpack --mode development --watch",
6464
"serve": "webpack serve --config-name mainServe --mode development",

packages/core/package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,30 @@
22
"name": "aws-core-vscode",
33
"description": "Core library used AWS IDE extensions for VSCode.",
44
"version": "1.0.0",
5+
"extensionKind": [
6+
"workspace"
7+
],
58
"publisher": "amazonwebservices",
69
"license": "Apache-2.0",
710
"engines": {
811
"npm": "^10.1.0",
912
"vscode": "^1.68.0"
1013
},
14+
"activationEvents": [
15+
"onStartupFinished",
16+
"onUri",
17+
"onDebugResolve:aws-sam",
18+
"onDebugInitialConfigurations",
19+
"onLanguage:javascript",
20+
"onLanguage:java",
21+
"onLanguage:python",
22+
"onLanguage:csharp",
23+
"onLanguage:yaml",
24+
"onFileSystem:s3",
25+
"onFileSystem:s3-readonly"
26+
],
27+
"main": "./dist/src/extensionNode.js",
28+
"browser": "./dist/src/extensionWebCore.js",
1129
"exports": {
1230
".": "./dist/src/extension.js",
1331
"./node": "./dist/src/extensionNode.js",
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
/**
7+
* This script is used to run unit tests from an npm script defined in package.json.
8+
* TODO: Generalize and use named args system from root/scripts/package.ts
9+
*
10+
* Usage:
11+
* node ./test/runToolkitTests.js <suite_name> <relative path to entrypoint> <relative path to workspace folder>
12+
*
13+
* where:
14+
* - suite_name, e.g. 'unit', 'integration', 'e2e'
15+
* - relative path to entrypoint: test entry point file built in .js, e.g. 'amazonq/dist/test/unit/index.js'
16+
* - relative path to workspace folder: folder to open the test VSC instance in (optional)
17+
*
18+
* See examples in any subproject's package.json `test` scripts.
19+
*/
20+
21+
import 'source-map-support/register'
22+
23+
import { runToolkitTests, SuiteName } from './launchTestUtilities'
24+
void (async () => {
25+
const suiteName = process.argv[2] as SuiteName
26+
if (!suiteName) {
27+
throw new Error('A test suite name is required.')
28+
}
29+
30+
const relativeEntrypoint = process.argv[3]
31+
if (!relativeEntrypoint) {
32+
throw new Error('A path relative to core is required.')
33+
}
34+
35+
const relativeWorkspaceFolder = process.argv[4]
36+
await runToolkitTests(suiteName, relativeEntrypoint, relativeWorkspaceFolder)
37+
})()

packages/core/scripts/test/launchTestUtilities.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ const minimum = 'minimum'
1818

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

21-
type SuiteName = 'integration' | 'e2e' | 'unit' | 'web'
21+
const suiteNames = ['integration', 'e2e', 'unit', 'web'] as const
22+
export type SuiteName = (typeof suiteNames)[number]
2223

2324
/**
2425
* This is the generalized method that is used by different test suites (unit, integration, ...) in CI to
@@ -35,6 +36,10 @@ export async function runToolkitTests(
3536
env?: Record<string, string>
3637
) {
3738
try {
39+
if (!suiteNames.includes(suite)) {
40+
throw new Error(`Invalid suite name: '${suite}'. Must be one of: ${suiteNames.join(',')}`)
41+
}
42+
3843
console.log(`Running ${suite} test suite...`)
3944

4045
const args = await getVSCodeCliArgs({

packages/core/scripts/test/test.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/core/scripts/test/testE2E.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/core/scripts/test/testInteg.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/core/scripts/test/testWeb.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/toolkit/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@
6969
"webCompile": "npm run clean && npm run buildScripts && webpack --config-name web",
7070
"webRun": "npx @vscode/test-web --open-devtools --browserOption=--disable-web-security --waitForDebugger=9222 --extensionDevelopmentPath=. .",
7171
"testCompile": "npm run clean && npm run buildScripts && npm run compileOnly",
72-
"test": "npm run testCompile && c8 --allowExternal ts-node ../core/scripts/test/test.ts dist/test/unit/index.js ../core/dist/src/testFixtures/workspaceFolder",
73-
"testE2E": "npm run testCompile && c8 --allowExternal ts-node ../core/scripts/test/testE2E.ts dist/test/e2e/index.js ../core/dist/src/testFixtures/workspaceFolder",
74-
"testInteg": "npm run testCompile && c8 --allowExternal ts-node ../core/scripts/test/testInteg.ts dist/test/integ/index.js ../core/dist/src/testFixtures/workspaceFolder",
75-
"testWeb": "npm run compileDev && c8 --allowExternal ts-node ../core/scripts/test/testWeb.ts dist/test/web/index.js ../core/dist/src/testFixtures/workspaceFolder",
72+
"test": "npm run testCompile && c8 --allowExternal ts-node ../core/scripts/test/launchTest.ts unit dist/test/unit/index.js ../core/dist/src/testFixtures/workspaceFolder",
73+
"testE2E": "npm run testCompile && c8 --allowExternal ts-node ../core/scripts/test/launchTest.ts e2e dist/test/e2e/index.js ../core/dist/src/testFixtures/workspaceFolder",
74+
"testInteg": "npm run testCompile && c8 --allowExternal ts-node ../core/scripts/test/launchTest.ts integration dist/test/integ/index.js ../core/dist/src/testFixtures/workspaceFolder",
75+
"testWeb": "npm run compileDev && c8 --allowExternal ts-node ../core/scripts/test/launchTest.ts web dist/test/web/index.js ../core/dist/src/testFixtures/workspaceFolder",
7676
"package": "ts-node ../../scripts/package.ts",
7777
"install-plugin": "vsce package --ignoreFile '../.vscodeignore.packages' -o aws-toolkit-vscode-test.vsix && code --install-extension aws-toolkit-vscode-test.vsix",
7878
"lint": "true",

0 commit comments

Comments
 (0)