6a1a17dd28
* Add css hmr test * Allow HMR in e2e tests * Add changeset * Actually fix test * Fix lint * Skip windows for now
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
import { test as testBase, expect } from '@playwright/test';
|
|
import { loadFixture as baseLoadFixture } from '../test/test-utils.js';
|
|
|
|
export const isWindows = process.platform === 'win32';
|
|
|
|
export function loadFixture(inlineConfig) {
|
|
if (!inlineConfig || !inlineConfig.root)
|
|
throw new Error("Must provide { root: './fixtures/...' }");
|
|
|
|
// resolve the relative root (i.e. "./fixtures/tailwindcss") to a full filepath
|
|
// without this, the main `loadFixture` helper will resolve relative to `packages/astro/test`
|
|
return baseLoadFixture({
|
|
...inlineConfig,
|
|
root: new URL(inlineConfig.root, import.meta.url).toString(),
|
|
});
|
|
}
|
|
|
|
export function testFactory(inlineConfig) {
|
|
let fixture;
|
|
|
|
const test = testBase.extend({
|
|
astro: async ({}, use) => {
|
|
fixture = fixture || (await loadFixture(inlineConfig));
|
|
await use(fixture);
|
|
},
|
|
});
|
|
|
|
test.afterEach(() => {
|
|
fixture.resetAllFiles();
|
|
});
|
|
|
|
return test;
|
|
}
|
|
|
|
export async function getErrorOverlayMessage(page) {
|
|
const overlay = await page.waitForSelector('vite-error-overlay', {
|
|
strict: true,
|
|
timeout: 10 * 1000,
|
|
});
|
|
|
|
expect(overlay).toBeTruthy();
|
|
|
|
return await overlay.$$eval('.message-body', (m) => m[0].textContent);
|
|
}
|
|
|
|
/**
|
|
* @param {import('@playwright/test').Locator} el
|
|
* @returns {Promise<string>}
|
|
*/
|
|
export async function getColor(el) {
|
|
return await el.evaluate((e) => getComputedStyle(e).color);
|
|
}
|