Skip to content

Commit 38e80e8

Browse files
e2e tweaks to help debug. (#1098)
Aligns with other Foundation projects.
1 parent b6ea84d commit 38e80e8

15 files changed

+50
-19
lines changed

package-lock.json

+28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"@testing-library/user-event": "^12.8.3",
6262
"@types/file-saver": "^2.0.3",
6363
"@types/jest": "^26.0.24",
64+
"cross-env": "^7.0.3",
6465
"pptr-testing-library": "^0.7.0",
6566
"prettier": "2.3.2",
6667
"puppeteer": "^13.4.0",
@@ -84,8 +85,8 @@
8485
"serve": "npx serve --no-clipboard -l 3000 -- build/",
8586
"typecheck": "tsc --noEmit",
8687
"test:all": "craco test --testTimeout 15000",
87-
"test:e2e": "craco test --testPathPattern e2e -w 1 --testTimeout 15000",
88-
"test:e2e:headless": "CI=true npm run test:e2e",
88+
"test:e2e": "cross-env E2E_HEADLESS=0 craco test --testPathPattern e2e -w 1 --testTimeout 15000",
89+
"test:e2e:headless": "cross-env E2E_HEADLESS=1 craco test --testPathPattern e2e -w 1 --testTimeout 15000",
8990
"ci:update-version": "update-ci-version",
9091
"deploy": "website-deploy-aws",
9192
"invalidate": "aws cloudfront create-invalidation --distribution-id $(printenv ${STAGE}_CLOUDFRONT_DISTRIBUTION_ID) --paths \"/*\"",

src/e2e/accessibility.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
import { App } from "./app";
77

8-
describe("Browser - accessibility", () => {
8+
describe("accessibility", () => {
99
const app = new App();
1010
beforeEach(app.reset.bind(app));
1111
afterEach(app.screenshot.bind(app));

src/e2e/app.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ export class App {
7575

7676
constructor(options: Options = {}) {
7777
this.url = this.optionsToURL(options);
78-
this.browser = puppeteer.launch();
78+
this.browser = puppeteer.launch({
79+
headless: process.env.E2E_HEADLESS !== "0",
80+
// Needs to be large enough to display Reference + Simulator or tests need to show/hide them.
81+
defaultViewport: { width: 1920, height: 1440 },
82+
});
7983
this.page = this.createPage();
8084
}
8185

@@ -116,8 +120,6 @@ export class App {
116120
]);
117121

118122
const page = await context.newPage();
119-
// Needs to be large enough to display Reference + Simulator or tests need to show/hide them.
120-
await page.setViewport({ width: 1920, height: 1440 });
121123
await page.setCookie({
122124
// See corresponding code in App.tsx.
123125
name: "mockDevice",
@@ -1095,7 +1097,7 @@ export class App {
10951097
tabName: "Project" | "API" | "Reference" | "Ideas"
10961098
): Promise<ElementHandle<Element>> {
10971099
const document = await this.document();
1098-
const tab = await document.getByRole("tab", {
1100+
const tab = await document.findByRole("tab", {
10991101
name: tabName,
11001102
});
11011103
await tab.click();

src/e2e/autocomplete.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { App } from "./app";
88
const showFullSignature =
99
"show(image, delay=400, wait=True, loop=False, clear=False)";
1010

11-
describe("Browser - autocomplete and signature help tests", () => {
11+
describe("autocomplete", () => {
1212
// Enable flags to allow testing the toolkit interactions.
1313
const app = new App();
1414
beforeEach(app.reset.bind(app));

src/e2e/connect.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const traceback = `Traceback (most recent call last):
1010
SyntaxError: invalid syntax
1111
`; // Needs trailing newline!
1212

13-
describe("Browser - WebUSB (mocked)", () => {
13+
describe("connect", () => {
1414
const app = new App();
1515
beforeEach(app.reset.bind(app));
1616
afterEach(app.screenshot.bind(app));

src/e2e/documentation.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
import { App } from "./app";
77

8-
describe("Browser - toolkit tabs", () => {
8+
describe("documentaion", () => {
99
const app = new App();
1010
beforeEach(app.reset.bind(app));
1111
afterEach(app.screenshot.bind(app));

src/e2e/edits.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
import { App } from "./app";
77

8-
describe("Browser - edits", () => {
8+
describe("edits", () => {
99
const app = new App();
1010
beforeEach(app.reset.bind(app));
1111
// We intentionally close the page so can't screenshot here.

src/e2e/migration.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const heartMigrationFragment =
1111
const sunlightSensorMigrationFragment =
1212
"#project:XQAAgAByAQAAAAAAAAA9iImmlGSt1R++5LD+ZJ36cRz46B+lhYtNRoWF0nijpaVyZlK7ACfSpeoQpgfk21st4ty06R4PEOW6kOsIEMK7SL0Qco7jgsHFKZXfjv/XcHWvXG9qyz1a/a3NUulFDj/FDJxVAIV+WZLpRoo4E6MbW70FOgIfBPWP2hDVsojpoLc7ZfKI8SHxv54FSfB5bkbzaAKO+8CO73t6Odtv691JGjJ9MExFighY6GxyM/DoNInDDpAjFeaqCWrYdwENX7ZVM3we8f4swI71tL28N7sg588aB//A78AA";
1313

14-
describe("Browser - migration", () => {
14+
describe("migration", () => {
1515
const app = new App({
1616
fragment: heartMigrationFragment,
1717
});

src/e2e/multiple-files.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
import { App, LoadDialogType } from "./app";
77

8-
describe("Browser - multiple and missing file cases", () => {
8+
describe("multiple-files", () => {
99
const app = new App();
1010
beforeEach(app.reset.bind(app));
1111
afterEach(app.screenshot.bind(app));

src/e2e/open.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
import { App, LoadDialogType } from "./app";
77

8-
describe("Browser - open", () => {
8+
describe("open", () => {
99
const app = new App();
1010
beforeEach(app.reset.bind(app));
1111
afterEach(app.screenshot.bind(app));

src/e2e/reset.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
*
44
* SPDX-License-Identifier: MIT
55
*/
6-
import { App, LoadDialogType } from "./app";
6+
import { App } from "./app";
77

8-
describe("Browser - reset", () => {
8+
describe("reset", () => {
99
const app = new App();
1010
beforeEach(app.reset.bind(app));
1111
afterEach(app.screenshot.bind(app));

src/e2e/save.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
import { App, LoadDialogType } from "./app";
77

8-
describe("Browser - save", () => {
8+
describe("save", () => {
99
const app = new App();
1010
beforeEach(app.reset.bind(app));
1111
afterEach(app.screenshot.bind(app));

src/e2e/settings.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
import { App } from "./app";
77

8-
describe("Browser - settings", () => {
8+
describe("settings", () => {
99
const app = new App();
1010
beforeEach(() => {
1111
app.setOptions({});

src/e2e/simulator.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const gestureTest =
1616
const sliderTest =
1717
"from microbit import *\nwhile True:\nif temperature() == -5:\ndisplay.show(Image.NO)";
1818

19-
describe("Browser - simulator", () => {
19+
describe("simulator", () => {
2020
const app = new App();
2121
beforeEach(app.reset.bind(app));
2222
afterEach(app.screenshot.bind(app));

0 commit comments

Comments
 (0)