Skip to content

Commit

Permalink
[AXON-37] chore: move E2E tests to a dedicated folder
Browse files Browse the repository at this point in the history
  • Loading branch information
sdzh-atlassian committed Dec 16, 2024
1 parent cd3953a commit c96d221
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ yalc.lock
.env
coverage
.test-extensions/
generated/
.generated/
e2e/.resources/
3 changes: 3 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# images/
# LICENSE

.generated/
e2e/

.env
.env.example
.eslintignore
Expand Down
29 changes: 29 additions & 0 deletions e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
### What am I looking at?

This folder is for end-to-end ("e2e") tests and their configuration.

In `atlascode`, we use [vscode-extension-tester](https://github.com/redhat-developer/vscode-extension-tester) to run browser automation-style tests agains ta developer instance of VSCode with the extension installed

How do these tests work?

- `extester`, the executable from `vscode-extension-tester`, compiles and packages the extensions using `vsce`
- A new instance of `vscode` is spun up, with `atlascode` and prerequisites installed
- A special automation performs the actions we describe in test suites

What do these tests use?

- `mocha` for orchestration
- `chai` for assertions

Commands related to e2e tests:

# Compile the tests in this folder into JS
npm run e2e:compile

# Build the extension, e2e tests, configure the test runner,
# then run the E2E tests
npm run e2e

# Run the tests without rebuilding the extension
# Use this one when iterating
npm run e2e:rerun
15 changes: 15 additions & 0 deletions e2e/scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

command="setup-and-run"

if [ "$1" == "--rerun" ]; then
# Skip rebuilding the extension and setting up the tests
# Use this if you are iterating in the tests themselves
command="run-tests"
fi

extest ${command} \
'./.generated/atlascode/e2e/tests/*.test.js' \
--code_version max \
--code_settings e2e/test-settings.json \
--extensions_dir .test-extensions
2 changes: 1 addition & 1 deletion ui-test-settings.json → e2e/test-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"terminal.integrated.sendKeybindingsToShell": true,
"workbench.remoteIndicator.showExtensionRecommendations": false,
"extensions.ignoreRecommendations": true
}
}
7 changes: 7 additions & 0 deletions src/ui-test/dummy.test.ts → e2e/tests/dummy.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
// import the webdriver and the high level browser wrapper
import { assert } from 'chai';
import { before, VSBrowser, WebDriver } from 'vscode-extension-tester';
import { describe, it } from 'mocha';

// Let's make sure we can import something from the src folder if needed
import { AuthInfoVersionKey } from '../../src/constants';

// Create a Mocha suite
describe('My Test Suite', () => {
let browser: VSBrowser;
let driver: WebDriver;

console.log('Oh look, a constant from src!');
console.log('AuthInfoVersionKey:', AuthInfoVersionKey);

// initialize the browser and webdriver
before(async () => {
browser = VSBrowser.instance;
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.ui-test.json → e2e/tsconfig.e2e.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"baseUrl": ".",
"outDir": "generated/ui-test",
"outDir": "../.generated",
"module": "CommonJS",
"target": "es6",
"lib": ["esnext", "dom"],
Expand All @@ -12,7 +12,7 @@
"allowJs": true,
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src/ui-test",
"rootDir": "../..",
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
Expand All @@ -24,5 +24,5 @@
"noUnusedLocals": true,
"typeRoots": ["node_modules/@types", "src/typings/"]
},
"include": ["src/ui-test/**/*"],
"include": ["tests/**/*"]
}
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
],
},
transformIgnorePatterns: ['/node_modules/'],
testPathIgnorePatterns: ['/node_modules/', '<rootDir>/src/ui-test/'],
testPathIgnorePatterns: ['/node_modules/', '/e2e/'],
verbose: true,
setupFilesAfterEnv: ['<rootDir>/setupTests.js'],
// coverage configuration
Expand Down
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@
"vscode:uninstall": "node ./build/extension/uninstall.js",
"vscode:prepublish": "npm run compile",
"clean": "rm -rf ./build",
"format": "prettier --write --log-level warn src",
"lint": "eslint ./src --ext .js,.jsx,.ts,.tsx",
"lint:fix": "eslint --fix ./src --ext .js,.jsx,.ts,.tsx",
"compile:ui-test": "tsc --project tsconfig.ui-test.json",
"format": "prettier --write --log-level warn src e2e",
"lint": "eslint ./src ./e2e --ext .js,.jsx,.ts,.tsx",
"lint:fix": "eslint --fix ./src ./e2e --ext .js,.jsx,.ts,.tsx",
"compile": "npm run clean && npm run compile:react && npm run compile:extension",
"compile:extension": "NODE_OPTIONS=--openssl-legacy-provider webpack --mode production --config webpack.extension.prod.js",
"compile:react": "NODE_OPTIONS=--openssl-legacy-provider webpack --mode production --config webpack.react.prod.js",
Expand All @@ -63,7 +62,9 @@
"extension:package": "npm run extension:clean && vsce package --baseContentUrl https://raw.githubusercontent.com/atlassian/atlascode/main/ --allow-star-activation",
"extension:install": "npm run extension:package && code --install-extension ./atlascode-*.vsix --force",
"test": "jest",
"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",
"e2e:compile": "tsc --project e2e/tsconfig.e2e.json",
"e2e": "npm run e2e:compile && e2e/scripts/run.sh",
"e2e:rerun": "npm run e2e:compile && e2e/scripts/run.sh --rerun",
"devcompile": "npm-run-all --parallel devcompile:react devcompile:extension",
"devcompile:react": "webpack --mode development --config webpack.react.dev.js",
"devcompile:extension": "webpack --mode development --config webpack.extension.dev.js",
Expand Down Expand Up @@ -1480,6 +1481,7 @@
"@types/lodash.debounce": "^4.0.6",
"@types/lodash.orderby": "^4.6.6",
"@types/lodash.truncate": "^4.4.6",
"@types/mocha": "^10.0.10",
"@types/node": "^18.16.19",
"@types/node-ipc": "^9.2.0",
"@types/prosemirror-schema-basic": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"noUnusedLocals": true,
"typeRoots": ["node_modules/@types", "src/typings/"]
},
"include": ["**/src/**/*", "**/test/**/*", "webpack.*.js", "jest.config.js", "**/stories/**/*"],
"include": ["**/src/**/*", "**/test/**/*", "webpack.*.js", "jest.config.js", "**/stories/**/*", "e2e/**/*"],
"exclude": [
"out",
"node_modules",
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.notest.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"__fixtures__",
"**/__fixtures__",
"test",
".yalc"
".yalc",
"e2e",
]
}

0 comments on commit c96d221

Please sign in to comment.