-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: tag JSX exports with correct renderer * feat(error): enhance generic errors with frame * feat(error): surface errors from streaming response * feat(error): use vite overlay to display errors * chore: fix build issues * feat: use custom logger to hide vite errors for known packages * chore: move error-react-spectrum to e2e test * chore: add todo comment * test: fix error overlay handling * refactor: extract overlay message to util * test(e2e): update shared component tests * fix: give error overlay more time * refactor: move errors tests to e2e * fix: appease ts * test: move sass error to e2e tests * fix: scope optimizeDeps to `src/pages/**/*` * chore: update lockfile * chore: update test script * chore: log error overlay * chore: log error tests * chore: update playwright config * test(e2e): update errors tests * test(e2e): fix overlay util * test(e2e): fix test utils * test(e2e): try timeout * test(e2e): give up on overlay tests * fix: typo * fix: typo * refactor: collapse definition * fix: let errors throw * chore: revert scanner change * chore: refactor err.plugin handling * chore: add clarifying comments * fix: make astro:renderer non enumerable * chore: update comments * refactor: replace astro:renderer string with Symbol * chore: add comment about tagged components * feat: improve error overlay when hint exists Co-authored-by: Nate Moore <nate@astro.build>
- Loading branch information
1 parent
4ee997d
commit 4412fe6
Showing
68 changed files
with
452 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { expect } from '@playwright/test'; | ||
import { testFactory, getErrorOverlayMessage } from './test-utils.js'; | ||
|
||
const test = testFactory({ root: './fixtures/error-react-spectrum/' }); | ||
|
||
let devServer; | ||
|
||
test.beforeEach(async ({ astro }) => { | ||
devServer = await astro.startDevServer(); | ||
}); | ||
|
||
test.afterEach(async ({ astro }) => { | ||
await devServer.stop(); | ||
astro.resetAllFiles(); | ||
}); | ||
|
||
test.describe('Error: React Spectrum', () => { | ||
test('overlay', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/')); | ||
|
||
const message = await getErrorOverlayMessage(page); | ||
expect(message).toMatch('@adobe/react-spectrum is not compatible') | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { expect } from '@playwright/test'; | ||
import { testFactory, getErrorOverlayMessage } from './test-utils.js'; | ||
|
||
const test = testFactory({ root: './fixtures/error-sass/' }); | ||
|
||
let devServer; | ||
|
||
test.beforeEach(async ({ astro }) => { | ||
devServer = await astro.startDevServer(); | ||
}); | ||
|
||
test.afterEach(async ({ astro }) => { | ||
await devServer.stop(); | ||
astro.resetAllFiles(); | ||
}); | ||
|
||
test.describe('Error: Sass', () => { | ||
test('overlay', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/')); | ||
|
||
const message = await getErrorOverlayMessage(page); | ||
expect(message).toMatch('Undefined variable') | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { expect } from '@playwright/test'; | ||
import { testFactory, getErrorOverlayMessage } from './test-utils.js'; | ||
|
||
const test = testFactory({ root: './fixtures/errors/' }); | ||
|
||
let devServer; | ||
|
||
test.beforeEach(async ({ astro }) => { | ||
devServer = await astro.startDevServer(); | ||
}); | ||
|
||
test.afterEach(async ({ astro }) => { | ||
await devServer.stop(); | ||
astro.resetAllFiles(); | ||
}); | ||
|
||
test.describe('Error display', () => { | ||
test('detect syntax errors in template', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/astro-syntax-error')); | ||
|
||
const message = await getErrorOverlayMessage(page); | ||
expect(message).toMatch('Unexpected "}"') | ||
|
||
await Promise.all([ | ||
// Wait for page reload | ||
page.waitForNavigation(), | ||
// Edit the component file | ||
await astro.editFile('./src/pages/astro-syntax-error.astro', () => `<h1>No syntax error</h1>`) | ||
]); | ||
|
||
expect(await page.locator('vite-error-overlay').count()).toEqual(0); | ||
}); | ||
|
||
test('shows useful error when frontmatter import is not found', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/import-not-found')); | ||
|
||
const message = await getErrorOverlayMessage(page); | ||
expect(message).toMatch('failed to load module for ssr: ../abc.astro') | ||
|
||
await Promise.all([ | ||
// Wait for page reload | ||
page.waitForNavigation(), | ||
// Edit the component file | ||
astro.editFile('./src/pages/import-not-found.astro', () => `<h1>No import error</h1>`) | ||
]); | ||
|
||
expect(await page.locator('vite-error-overlay').count()).toEqual(0); | ||
}); | ||
|
||
test('framework errors recover when fixed', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/svelte-syntax-error')); | ||
|
||
const message = await getErrorOverlayMessage(page); | ||
expect(message).toMatch('</div> attempted to close an element that was not open') | ||
|
||
await Promise.all([ | ||
// Wait for page reload | ||
page.waitForNavigation(), | ||
// Edit the component file | ||
astro.editFile('./src/components/SvelteSyntaxError.svelte', () => `<h1>No mismatch</h1>`) | ||
]); | ||
|
||
expect(await page.locator('vite-error-overlay').count()).toEqual(0); | ||
}); | ||
|
||
|
||
}); |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ixtures/error-react-spectrum/package.json → ...ixtures/error-react-spectrum/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ges/astro/test/fixtures/sass/package.json → ...stro/e2e/fixtures/error-sass/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "@test/sass", | ||
"name": "@e2e/error-sass", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
|
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...s/astro/test/fixtures/errors/package.json → ...es/astro/e2e/fixtures/errors/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "@test/errors", | ||
"name": "@e2e/errors", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.