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

Split up e2e HMR test #3425

Merged
merged 1 commit into from
May 23, 2022
Merged
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
82 changes: 46 additions & 36 deletions packages/astro/e2e/multiple-frameworks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,41 +106,51 @@ test.describe('Multiple frameworks', () => {
await expect(bComponent, 'component text is visible').toHaveText('Hello Astro (B)');
});

test('HMR', async ({ astro, page }) => {
await page.goto('/');

// 1: updating the page template
const preactSlot = page.locator('#preact-counter + .counter-message');
await expect(preactSlot, 'initial slot content').toHaveText('Hello Preact!');

await astro.editFile('./src/pages/index.astro', (content) =>
content.replace('Hello Preact!', 'Hello Preact, updated!')
);

await expect(preactSlot, 'slot content updated').toHaveText('Hello Preact, updated!');

// Edit the react component
await astro.editFile('./src/components/ReactCounter.jsx', (content) =>
content.replace('useState(0)', 'useState(5)')
);

const reactCount = await page.locator('#react-counter pre');
await expect(reactCount, 'initial count updated to 5').toHaveText('5');

// 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 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)'
);
test.describe('HMR', () => {
test('Page template', async ({ astro, page }) => {
await page.goto('/');

// 1: updating the page template
const preactSlot = page.locator('#preact-counter + .counter-message');
await expect(preactSlot, 'initial slot content').toHaveText('Hello Preact!');

await astro.editFile('./src/pages/index.astro', (content) =>
content.replace('Hello Preact!', 'Hello Preact, updated!')
);

await expect(preactSlot, 'slot content updated').toHaveText('Hello Preact, updated!');
});

test('React component', async ({ astro, page }) => {
await page.goto('/');

// Edit the react component
await astro.editFile('./src/components/ReactCounter.jsx', (content) =>
content.replace('useState(0)', 'useState(5)')
);

const reactCount = await page.locator('#react-counter pre');
await expect(reactCount, 'initial count updated to 5').toHaveText('5');
});

test('Svelte component', async ({ astro, page }) => {
await page.goto('/');

// 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 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)'
);
});
});
});