Skip to content

Commit a749c41

Browse files
[AXON-32] (WIP) Use of RedHat UI testing framework vscode-extension-tester
* Simple working example * clean up mocha config, add dependency to package.json * clean tsconfig. Change test to a positive verificaiton. Note: I saw some flakes here * Reduce flakes. Don't get the y/n question * [AXON-32] compiling typescript tests manually * ts test work * lint * normal test should ignore ui-tests
1 parent 2d20902 commit a749c41

8 files changed

+3458
-229
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ TEMP-*
1515
.yalc
1616
yalc.lock
1717
.env
18-
coverage
18+
coverage
19+
.test-extensions/
20+
generated/

.mocharc.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// increase default test case timeout to 5 seconds
2+
module.exports = {
3+
"timeout": 5000,
4+
// For further investigation
5+
// "extension": ["ts"],
6+
// "exit": true,
7+
// "require": ["ts-node/register"],
8+
};

jest.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = {
1010
],
1111
},
1212
transformIgnorePatterns: ['/node_modules/'],
13+
testPathIgnorePatterns: ['/node_modules/', '<rootDir>/src/ui-test/'],
1314
verbose: true,
1415
setupFilesAfterEnv: ['<rootDir>/setupTests.js'],
1516
// coverage configuration

package-lock.json

+3,383-227
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"Other"
3636
],
3737
"activationEvents": [
38-
"*"
38+
"onStartupFinished"
3939
],
4040
"extensionDependencies": [
4141
"vscode.git",
@@ -53,6 +53,7 @@
5353
"format": "prettier --write . --log-level warn",
5454
"lint": "eslint ./src --ext .js,.jsx,.ts,.tsx",
5555
"lint:fix": "eslint --fix ./src --ext .js,.jsx,.ts,.tsx",
56+
"compile:ui-test": "tsc --project tsconfig.ui-test.json",
5657
"compile": "npm run clean && npm run compile:react && npm run compile:extension",
5758
"compile:extension": "NODE_OPTIONS=--openssl-legacy-provider webpack --mode production --config webpack.extension.prod.js",
5859
"compile:react": "NODE_OPTIONS=--openssl-legacy-provider webpack --mode production --config webpack.react.prod.js",
@@ -62,6 +63,7 @@
6263
"extension:package": "npm run extension:clean && vsce package --baseContentUrl https://raw.githubusercontent.com/atlassian/atlascode/main/ --allow-star-activation",
6364
"extension:install": "npm run extension:package && code --install-extension ./atlascode-*.vsix --force",
6465
"test": "jest",
66+
"test:ui": "npm run compile:ui-test && extest run-tests './generated/ui-test/*.test.js' --code_version max --code_settings ui-test-settings.json --extensions_dir .test-extensions",
6567
"devcompile": "npm-run-all --parallel devcompile:react devcompile:extension",
6668
"devcompile:react": "webpack --mode development --config webpack.react.dev.js",
6769
"devcompile:extension": "webpack --mode development --config webpack.extension.dev.js",
@@ -1466,6 +1468,7 @@
14661468
"@babel/core": "^7.25.0",
14671469
"@stylistic/eslint-plugin-js": "^2.8.0",
14681470
"@types/analytics-node": "^3.1.7",
1471+
"@types/chai": "^4",
14691472
"@types/deep-equal": "^1.0.1",
14701473
"@types/escape-string-regexp": "^1.0.0",
14711474
"@types/filesize": "^4.1.0",
@@ -1504,6 +1507,7 @@
15041507
"ajv-formats": "^3.0.1",
15051508
"autoprefixer": "^10.4.20",
15061509
"babel-loader": "^9.2.1",
1510+
"chai": "^4",
15071511
"cross-env": "^7.0.2",
15081512
"css-loader": "^7.1.2",
15091513
"css-minimizer-webpack-plugin": "^7.0.0",
@@ -1539,6 +1543,7 @@
15391543
"tsconfig-paths-webpack-plugin": "^3.2.0",
15401544
"typescript": "^5.4.0 <5.5.0",
15411545
"vsce": "^2.15.0",
1546+
"vscode-extension-tester": "^8.10.0",
15421547
"vue": "^3.2.23",
15431548
"webpack": "^5",
15441549
"webpack-cli": "^5.1.4",

src/ui-test/dummy.test.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// import the webdriver and the high level browser wrapper
2+
import { assert } from 'chai';
3+
import { before, VSBrowser, WebDriver } from 'vscode-extension-tester';
4+
5+
// Create a Mocha suite
6+
describe('My Test Suite', () => {
7+
let browser: VSBrowser;
8+
let driver: WebDriver;
9+
10+
// initialize the browser and webdriver
11+
before(async () => {
12+
browser = VSBrowser.instance;
13+
driver = browser.driver;
14+
});
15+
16+
// test whatever we want using webdriver, here we are just checking the page title
17+
it('My Test Case', async () => {
18+
const title = await driver.getTitle();
19+
assert.isTrue(title === 'Getting Started' || title === 'Walkthrough: Setup VS Code');
20+
});
21+
});

tsconfig.ui-test.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": ".",
4+
"outDir": "generated/ui-test",
5+
"module": "CommonJS",
6+
"target": "es6",
7+
"lib": ["esnext", "dom"],
8+
"skipDefaultLibCheck": true,
9+
"resolveJsonModule": true,
10+
"skipLibCheck": true,
11+
"sourceMap": true,
12+
"allowJs": true,
13+
"jsx": "react",
14+
"moduleResolution": "node",
15+
"rootDir": "src/ui-test",
16+
"allowSyntheticDefaultImports": true,
17+
"forceConsistentCasingInFileNames": true,
18+
"noImplicitReturns": true,
19+
"noImplicitThis": true,
20+
"noImplicitAny": true,
21+
"strictNullChecks": true,
22+
"suppressImplicitAnyIndexErrors": true,
23+
"ignoreDeprecations": "5.0",
24+
"noUnusedLocals": true,
25+
"typeRoots": ["node_modules/@types", "src/typings/"]
26+
},
27+
"include": ["src/ui-test/**/*"],
28+
}

ui-test-settings.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"typescript.updateImportsOnFileMove.enabled": "always",
3+
"workbench.editor.enablePreview": true,
4+
"git.autoRepositoryDetection": false,
5+
"terminal.integrated.sendKeybindingsToShell": true,
6+
"workbench.remoteIndicator.showExtensionRecommendations": false,
7+
"extensions.ignoreRecommendations": true
8+
}

0 commit comments

Comments
 (0)