Skip to content

Commit

Permalink
refactor: change e2e-cases to be 1 in multi project e2e and change it…
Browse files Browse the repository at this point in the history
… to be called latest (#1036)
  • Loading branch information
idoros committed May 23, 2024
1 parent fd939f2 commit fd2d16d
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 24 deletions.
17 changes: 4 additions & 13 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"${workspaceRoot}/fixtures/demo",
"--extensionDevelopmentPath=${workspaceRoot}"
],
"args": ["${workspaceRoot}/fixtures/demo", "--extensionDevelopmentPath=${workspaceRoot}"],
"stopOnEntry": false,
"sourceMaps": true,
"preLaunchTask": "compile"
Expand All @@ -19,9 +16,7 @@
"type": "node",
"request": "attach",
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/dist/src/lib/**/*.js"
],
"outFiles": ["${workspaceRoot}/dist/src/lib/**/*.js"],
"protocol": "inspector"
},
{
Expand All @@ -30,7 +25,7 @@
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"${workspaceRoot}/fixtures/e2e-cases",
"${workspaceRoot}/fixtures/latest",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/dist/test/e2e"
],
Expand All @@ -44,11 +39,7 @@
"type": "node",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"stopOnEntry": false,
"args": [
"-r",
"@ts-tools/node/r",
"test/unit/**/*.spec.ts"
],
"args": ["-r", "@ts-tools/node/r", "test/unit/**/*.spec.ts"],
"cwd": "${workspaceRoot}",
"protocol": "inspector"
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 9 additions & 4 deletions run-e2e-tests.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
// @ts-check
const path = require('path');
const { runTests } = require('@vscode/test-electron');

async function main() {
async function runSuite(suiteName) {
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = __dirname;

// The path to the extension test script
// Passed to --extensionTestsPath
const extensionTestsPath = path.join(__dirname, './dist/test/e2e/index');
const extensionTestsPath = path.join(__dirname, `./dist/test/e2e/${suiteName}/index`);

// path to the test fixtures (root directory of test contexts)
const pathToOpen = path.join(extensionDevelopmentPath, 'fixtures', 'e2e-cases');
const pathToOpen = path.join(extensionDevelopmentPath, 'fixtures', suiteName);

// Download VS Code, unzip it and run the integration test
await runTests({
Expand All @@ -26,4 +27,8 @@ async function main() {
}
}

main();
async function runAllSuites() {
await runSuite('latest');
}

runAllSuites();
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ suite('Extension Tests', function () {
});

async function getWorkingDocument(fileToTest: string) {
const casesPath = path.join(rootDir!, 'fixtures', 'e2e-cases', fileToTest);
const casesPath = path.join(rootDir!, 'fixtures', 'latest', fileToTest);
const ext = vscode.extensions.getExtension('wix.stylable-intelligence');

if (ext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ suite('test diagnostics', function () {
});

test('should support single file error', async () => {
const casePath = path.join(rootDir, 'fixtures', 'e2e-cases', 'single-file-diag.st.css');
const casePath = path.join(rootDir, 'fixtures', 'latest', 'single-file-diag.st.css');
const ext = vscode.extensions.getExtension<LanguageClient>('wix.stylable-intelligence');

if (ext) {
Expand All @@ -59,7 +59,7 @@ suite('test diagnostics', function () {
});

test('should resolve a configured alias with no diagnostics', async () => {
const casePath = path.join(rootDir, 'fixtures', 'e2e-cases', 'with-alias.st.css');
const casePath = path.join(rootDir, 'fixtures', 'latest', 'with-alias.st.css');
const ext = vscode.extensions.getExtension<LanguageClient>('wix.stylable-intelligence');

if (ext) {
Expand Down
5 changes: 5 additions & 0 deletions test/e2e/latest/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { collectAndRunTests } from '../../lsp-testkit/collect-and-run-tests';

export function run() {
return collectAndRunTests({ testsRoot: __dirname, suiteName: 'latest' });
}
13 changes: 9 additions & 4 deletions test/e2e/index.ts → test/lsp-testkit/collect-and-run-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ import { normalize } from 'path';
import Mocha from 'mocha';
import { glob } from 'glob';

const testsRoot = __dirname;

export async function run(): Promise<void> {
export async function collectAndRunTests({
testsRoot,
suiteName,
}: {
testsRoot: string;
suiteName: string;
}): Promise<void> {
console.log(`\nRunning tests for "${suiteName}"`);
const mocha = new Mocha({
ui: 'tdd',
color: true,
});
const testFilePaths = await glob('**/**.test.js', { cwd: testsRoot, absolute: true });
const testFilePaths = await glob(`**/**.test.js`, { cwd: testsRoot, absolute: true });
for (const filePath of testFilePaths) {
mocha.addFile(normalize(filePath));
}
Expand Down

0 comments on commit fd2d16d

Please sign in to comment.