[ci] format

This commit is contained in:
tony-sull 2022-05-23 16:57:55 +00:00 committed by github-actions[bot]
parent ff56f083bc
commit d0720ccfb4
3 changed files with 48 additions and 43 deletions

View file

@ -101,7 +101,6 @@ test.describe('Multiple frameworks', () => {
await expect(aComponent, 'component is visible').toBeVisible();
await expect(aComponent, 'component text is visible').toHaveText('Hello Astro (A)');
const bComponent = await page.locator('#astro-b');
await expect(bComponent, 'component is visible').toBeVisible();
await expect(bComponent, 'component text is visible').toHaveText('Hello Astro (B)');
@ -130,12 +129,18 @@ test.describe('Multiple frameworks', () => {
// Edit the svelte component's style
const svelteCounter = page.locator('#svelte-counter');
await expect(svelteCounter, 'initial background is white').toHaveCSS('background-color', 'rgb(255, 255, 255)');
await expect(svelteCounter, 'initial background is white').toHaveCSS(
'background-color',
'rgb(255, 255, 255)'
);
await astro.editFile('./src/components/SvelteCounter.svelte', (content) =>
content.replace('background: white', 'background: rgb(230, 230, 230)')
);
await expect(svelteCounter, 'background color updated').toHaveCSS('background-color', 'rgb(230, 230, 230)');
await expect(svelteCounter, 'background color updated').toHaveCSS(
'background-color',
'rgb(230, 230, 230)'
);
});
});

View file

@ -3,40 +3,39 @@ import { devices } from '@playwright/test';
const config = {
testMatch: 'e2e/*.test.js',
/* Maximum time one test can run for. */
timeout: 30 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 5000
},
/* Fail the build on CI if you accidentally left test in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: process.env.PLAYWRIGHT_TEST_BASE_URL || 'http://localhost:3000',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
projects: [
{
name: 'Chrome Stable',
use: {
browserName: 'chromium',
channel: 'chrome',
},
},
],
timeout: 30 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 5000,
},
/* Fail the build on CI if you accidentally left test in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: process.env.PLAYWRIGHT_TEST_BASE_URL || 'http://localhost:3000',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
projects: [
{
name: 'Chrome Stable',
use: {
browserName: 'chromium',
channel: 'chrome',
},
},
],
};
export default config;

View file

@ -98,7 +98,7 @@ export async function loadFixture(inlineConfig) {
const resolveUrl = (url) =>
`http://${'127.0.0.1'}:${config.server.port}${url.replace(/^\/?/, '/')}`;
// A map of files that have been editted.
let fileEdits = new Map();
@ -112,7 +112,7 @@ export async function loadFixture(inlineConfig) {
const onNextChange = () =>
devServer
? new Promise((resolve) => devServer.watcher.once('change', resolve))
: Promise.reject(new Error('No dev server running'))
: Promise.reject(new Error('No dev server running'));
// After each test, reset each of the edits to their original contents.
if (typeof afterEach === 'function') {
@ -155,21 +155,22 @@ export async function loadFixture(inlineConfig) {
const contents = await fs.promises.readFile(fileUrl, 'utf-8');
const reset = () => {
fs.writeFileSync(fileUrl, contents);
}
};
// Only save this reset if not already in the map, in case multiple edits happen
// to the same file.
if (!fileEdits.has(fileUrl.toString())) {
fileEdits.set(fileUrl.toString(), reset);
}
const newContents = typeof newContentsOrCallback === 'function'
? newContentsOrCallback(contents)
: newContentsOrCallback;
const newContents =
typeof newContentsOrCallback === 'function'
? newContentsOrCallback(contents)
: newContentsOrCallback;
const nextChange = onNextChange();
await fs.promises.writeFile(fileUrl, newContents);
await nextChange;
return reset;
},
resetAllFiles
resetAllFiles,
};
}