Skip to content

Commit

Permalink
Deflake tests
Browse files Browse the repository at this point in the history
There was a race when we didn't wait for the command palette to close.

Also updates the way wdio loads chrome, the previous method using
wdio-chromedriver-service was deprecated.
  • Loading branch information
dstoc committed May 7, 2024
1 parent c283abb commit 02c862e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 37 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"ts-node": "^10.9.2",
"typescript": "^5.4.5",
"vite": "^5.2.11",
"wdio-chromedriver-service": "^8.1.1",
"web-tree-sitter": "^0.22.6",
"webdriverio": "^8.24.1"
}
Expand Down
29 changes: 0 additions & 29 deletions pnpm-lock.yaml

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

4 changes: 3 additions & 1 deletion test/pages/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ type Status = 'loading' | 'loaded' | 'error';
export class Main extends Page {
path = '/?no-default&debug';
host = $('>>>pkm-editor');
dialog = $('>>>dialog[open]');
isReady = this.host.shadow$('*').isExisting;
fileSystem = new FileSystem();
isClean = async () => (await this.host.getAttribute('dirty')) === null;
async status(...status: Status[]): Promise<Status> {
await browser.waitUntil(async () =>
status.includes((await this.host.getAttribute('status')) as Status),
Expand All @@ -33,10 +33,12 @@ export class Main extends Page {
await browser.keys(control('p'));
await browser.keys(command.split(''));
await browser.keys('\n');
// TODO: Does the component correctly buffer these keystrokes?
if (argument !== undefined) {
await browser.keys(argument.split(''));
await browser.keys('\n');
}
await this.host.$('>>>dialog[open]').waitForExist({reverse: true});
}
}

Expand Down
2 changes: 0 additions & 2 deletions test/specs/edit_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ describe('main', () => {
}
async function checkExport(file: string, output: string) {
output = removeLeadingWhitespace(output);
await browser.waitUntil(state.main.isClean);
await state.main.runCommand('Export to OPFS');
const contents = await state.fs.getFile(file);
await state.fs.clear();
Expand Down Expand Up @@ -82,7 +81,6 @@ describe('main', () => {
\`\`\`
`,
);
// TODO: does not wait for save
await checkExport('transclusion.md', 'content\n');
});
it('can be inserted and deleted', async () => {
Expand Down
8 changes: 4 additions & 4 deletions test/wdio.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import {browser} from '@wdio/globals';
import type {Options} from '@wdio/types';
import * as os from 'os';

const instances = Math.max(1, Math.round(os.cpus().length / 2));
const instances = Math.max(1, Math.round(os.cpus().length * 0.75));
export const config: Options.Testrunner = {
runner: 'local',
autoCompileOpts: {
autoCompile: true,
tsNodeOpts: {transpileOnly: true, project: 'test/tsconfig.json'},
Expand All @@ -27,7 +28,7 @@ export const config: Options.Testrunner = {
maxInstances: instances,
capabilities: [
{
maxInstances: instances,
'wdio:maxInstances': instances,
browserName: 'chrome',
acceptInsecureCerts: true,
'goog:chromeOptions': {
Expand All @@ -36,15 +37,14 @@ export const config: Options.Testrunner = {
},
},
],
// Level of logging verbosity: trace | debug | info | warn | error | silent
logLevel: 'warn',
outputDir: 'test/logs',
bail: 0,
baseUrl: 'http://localhost:4173',
waitforTimeout: 10000,
connectionRetryTimeout: 120000,
connectionRetryCount: 3,
services: ['chromedriver'],
services: [],
framework: 'jasmine',
reporters: ['spec'],
jasmineOpts: {
Expand Down

0 comments on commit 02c862e

Please sign in to comment.