Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing perf improvements for e2e tests #4354

Merged
merged 4 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/astro/e2e/astro-component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ const test = testFactory({ root: './fixtures/astro-component/' });

let devServer;

test.beforeEach(async ({ astro }) => {
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async () => {
test.afterAll(async () => {
await devServer.stop();
});

Expand Down
4 changes: 2 additions & 2 deletions packages/astro/e2e/client-only.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const test = testFactory({ root: './fixtures/client-only/' });

let devServer;

test.beforeEach(async ({ astro }) => {
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async () => {
test.afterAll(async () => {
await devServer.stop();
});

Expand Down
5 changes: 2 additions & 3 deletions packages/astro/e2e/error-react-spectrum.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ const test = testFactory({ root: './fixtures/error-react-spectrum/' });

let devServer;

test.beforeEach(async ({ astro }) => {
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async ({ astro }) => {
test.afterAll(async ({ astro }) => {
await devServer.stop();
astro.resetAllFiles();
});

test.describe('Error: React Spectrum', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/e2e/error-sass.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const test = testFactory({ root: './fixtures/error-sass/' });

let devServer;

test.beforeEach(async ({ astro }) => {
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async ({ astro }) => {
test.afterAll(async ({ astro }) => {
await devServer.stop();
astro.resetAllFiles();
});
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/e2e/errors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const test = testFactory({ root: './fixtures/errors/' });

let devServer;

test.beforeEach(async ({ astro }) => {
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async ({ astro }) => {
test.afterAll(async ({ astro }) => {
await devServer.stop();
astro.resetAllFiles();
});
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/e2e/invalidate-script-deps.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ const test = testFactory({

let devServer;

test.beforeEach(async ({ astro }) => {
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async () => {
test.afterAll(async () => {
await devServer.stop();
});

Expand Down
10 changes: 5 additions & 5 deletions packages/astro/e2e/lit-component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ const test = testFactory({
// TODO: configure playwright to handle web component APIs
// https://github.com/microsoft/playwright/issues/14241
test.describe('Lit components', () => {
test.beforeEach(() => {
test.beforeAll(() => {
delete globalThis.window;
});

test.describe('Development', () => {
let devServer;
const t = test.extend({});

t.beforeEach(async ({ astro }) => {
t.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

t.afterEach(async () => {
t.afterAll(async () => {
await devServer.stop();
});

Expand Down Expand Up @@ -120,11 +120,11 @@ test.describe('Lit components', () => {
await astro.build();
});

t.beforeEach(async ({ astro }) => {
t.beforeAll(async ({ astro }) => {
previewServer = await astro.preview();
});

t.afterEach(async () => {
t.afterAll(async () => {
await previewServer.stop();
});

Expand Down
4 changes: 2 additions & 2 deletions packages/astro/e2e/multiple-frameworks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const test = testFactory({ root: './fixtures/multiple-frameworks/' });

let devServer;

test.beforeEach(async ({ astro }) => {
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async () => {
test.afterAll(async () => {
await devServer.stop();
});

Expand Down
4 changes: 2 additions & 2 deletions packages/astro/e2e/namespaced-component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ const test = testFactory({

let devServer;

test.beforeEach(async ({ astro }) => {
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async () => {
test.afterAll(async () => {
await devServer.stop();
});

Expand Down
4 changes: 2 additions & 2 deletions packages/astro/e2e/nested-in-preact.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const test = testFactory({ root: './fixtures/nested-in-preact/' });

let devServer;

test.beforeEach(async ({ astro }) => {
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async () => {
test.afterAll(async () => {
await devServer.stop();
});

Expand Down
4 changes: 2 additions & 2 deletions packages/astro/e2e/nested-in-react.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const test = testFactory({ root: './fixtures/nested-in-react/' });

let devServer;

test.beforeEach(async ({ astro }) => {
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async () => {
test.afterAll(async () => {
await devServer.stop();
});

Expand Down
4 changes: 2 additions & 2 deletions packages/astro/e2e/nested-in-solid.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const test = testFactory({ root: './fixtures/nested-in-solid/' });

let devServer;

test.beforeEach(async ({ astro }) => {
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async () => {
test.afterAll(async () => {
await devServer.stop();
});

Expand Down
4 changes: 2 additions & 2 deletions packages/astro/e2e/nested-in-svelte.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const test = testFactory({ root: './fixtures/nested-in-svelte/' });

let devServer;

test.beforeEach(async ({ astro }) => {
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async () => {
test.afterAll(async () => {
await devServer.stop();
});

Expand Down
4 changes: 2 additions & 2 deletions packages/astro/e2e/nested-in-vue.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const test = testFactory({ root: './fixtures/nested-in-vue/' });

let devServer;

test.beforeEach(async ({ astro }) => {
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async () => {
test.afterAll(async () => {
await devServer.stop();
});

Expand Down
4 changes: 2 additions & 2 deletions packages/astro/e2e/nested-recursive.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ const test = base.extend({

let devServer;

test.beforeEach(async ({ astro }) => {
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async () => {
test.afterAll(async () => {
await devServer.stop();
});

Expand Down
4 changes: 2 additions & 2 deletions packages/astro/e2e/nested-styles.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const test = testFactory({ root: './fixtures/nested-styles/' });

let devServer;

test.beforeEach(async ({ astro }) => {
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async () => {
test.afterAll(async () => {
await devServer.stop();
});

Expand Down
4 changes: 2 additions & 2 deletions packages/astro/e2e/pass-js.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ const test = testFactory({

let devServer;

test.beforeEach(async ({ astro }) => {
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async () => {
test.afterAll(async () => {
await devServer.stop();
});

Expand Down
4 changes: 2 additions & 2 deletions packages/astro/e2e/shared-component-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export function prepareTestFactory(opts) {

let devServer;

test.beforeEach(async ({ astro }) => {
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async () => {
test.afterAll(async () => {
await devServer.stop();
});

Expand Down
4 changes: 2 additions & 2 deletions packages/astro/e2e/solid-recurse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const test = testFactory({ root: './fixtures/solid-recurse/' });

let devServer;

test.beforeEach(async ({ astro }) => {
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async () => {
test.afterAll(async () => {
await devServer.stop();
});

Expand Down
4 changes: 2 additions & 2 deletions packages/astro/e2e/tailwindcss.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const test = testFactory({ root: './fixtures/tailwindcss/' });

let devServer;

test.beforeEach(async ({ astro }) => {
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async ({ astro }) => {
test.afterAll(async ({ astro }) => {
await devServer.stop();
astro.resetAllFiles();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/e2e/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function testFactory(inlineConfig) {

const test = testBase.extend({
astro: async ({}, use) => {
fixture = await loadFixture(inlineConfig);
fixture = fixture || await loadFixture(inlineConfig);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's it? Amazing!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the one! Test suites using beforeAll for firing up the dev server also helps speed up suites a bit

await use(fixture);
},
});
Expand Down
9 changes: 3 additions & 6 deletions packages/astro/e2e/ts-resolution.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ test.describe('TypeScript resolution -', () => {

let devServer;

t.beforeEach(async ({ astro }) => {
t.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

t.afterEach(async () => {
t.afterAll(async () => {
await devServer.stop();
});

Expand All @@ -44,13 +44,10 @@ test.describe('TypeScript resolution -', () => {

t.beforeAll(async ({ astro }) => {
await astro.build();
});

t.beforeEach(async ({ astro }) => {
previewServer = await astro.preview();
});

t.afterEach(async () => {
t.afterAll(async () => {
await previewServer.stop();
});

Expand Down