Cleanup test debugging (#2250)
This commit is contained in:
parent
b214b095f3
commit
305ce4182f
5 changed files with 52 additions and 6 deletions
|
@ -29,7 +29,6 @@ describe('nested layouts', () => {
|
|||
const stylesheets = $('link[rel=stylesheet]')
|
||||
.toArray()
|
||||
.map((el) => el.attribs.href);
|
||||
console.log({ stylesheets });
|
||||
|
||||
// page-one.[hash].css exists
|
||||
expect(stylesheets.some((href) => /page-one\.\w+\.css/.test(href))).to.be.true;
|
||||
|
|
|
@ -37,7 +37,6 @@ describe('Dynamic components', () => {
|
|||
// test 1: <astro-root> is empty
|
||||
expect($('<astro-root>').html()).to.equal('');
|
||||
const script = $('script').text();
|
||||
console.log(script);
|
||||
|
||||
// Grab the svelte import
|
||||
// const exp = /import\("(.+?)"\)/g;
|
||||
|
|
|
@ -19,39 +19,53 @@ describe('Error display', () => {
|
|||
describe('Astro', () => {
|
||||
it('syntax error in template', async () => {
|
||||
const res = await fixture.fetch('/astro-syntax-error');
|
||||
|
||||
expect(res.status).to.equal(500);
|
||||
|
||||
const body = await res.text();
|
||||
console.log(res.body);
|
||||
|
||||
expect(body).to.include('Unexpected "}"');
|
||||
});
|
||||
|
||||
it('syntax error in frontmatter', async () => {
|
||||
const res = await fixture.fetch('/astro-frontmatter-syntax-error');
|
||||
|
||||
expect(res.status).to.equal(500);
|
||||
|
||||
const body = await res.text();
|
||||
console.log(res.body);
|
||||
|
||||
expect(body).to.include('Unexpected end of frontmatter');
|
||||
});
|
||||
|
||||
it('runtime error', async () => {
|
||||
const res = await fixture.fetch('/astro-runtime-error');
|
||||
|
||||
expect(res.status).to.equal(500);
|
||||
|
||||
const body = await res.text();
|
||||
|
||||
expect(body).to.include('ReferenceError: title is not defined');
|
||||
|
||||
// TODO: improve and test stacktrace
|
||||
});
|
||||
|
||||
it('hydration error', async () => {
|
||||
const res = await fixture.fetch('/astro-hydration-error');
|
||||
|
||||
expect(res.status).to.equal(500);
|
||||
|
||||
const body = await res.text();
|
||||
|
||||
expect(body).to.include('Error: invalid hydration directive');
|
||||
});
|
||||
|
||||
it('client:media error', async () => {
|
||||
const res = await fixture.fetch('/astro-client-media-error');
|
||||
|
||||
expect(res.status).to.equal(500);
|
||||
|
||||
const body = await res.text();
|
||||
|
||||
expect(body).to.include('Error: Media query must be provided');
|
||||
});
|
||||
});
|
||||
|
@ -59,15 +73,21 @@ describe('Error display', () => {
|
|||
describe('JS', () => {
|
||||
it('syntax error', async () => {
|
||||
const res = await fixture.fetch('/js-syntax-error');
|
||||
|
||||
expect(res.status).to.equal(500);
|
||||
|
||||
const body = await res.text();
|
||||
|
||||
expect(body).to.include('Parse failure');
|
||||
});
|
||||
|
||||
it('runtime error', async () => {
|
||||
const res = await fixture.fetch('/js-runtime-error');
|
||||
|
||||
expect(res.status).to.equal(500);
|
||||
|
||||
const body = await res.text();
|
||||
|
||||
expect(body).to.include('ReferenceError: undefinedvar is not defined');
|
||||
});
|
||||
});
|
||||
|
@ -75,15 +95,21 @@ describe('Error display', () => {
|
|||
describe('Preact', () => {
|
||||
it('syntax error', async () => {
|
||||
const res = await fixture.fetch('/preact-syntax-error');
|
||||
|
||||
expect(res.status).to.equal(500);
|
||||
|
||||
const body = await res.text();
|
||||
|
||||
expect(body).to.include('Syntax error');
|
||||
});
|
||||
|
||||
it('runtime error', async () => {
|
||||
const res = await fixture.fetch('/preact-runtime-error');
|
||||
|
||||
expect(res.status).to.equal(500);
|
||||
|
||||
const body = await res.text();
|
||||
|
||||
expect(body).to.include('Error: PreactRuntimeError');
|
||||
});
|
||||
});
|
||||
|
@ -91,15 +117,21 @@ describe('Error display', () => {
|
|||
describe('React', () => {
|
||||
it('syntax error', async () => {
|
||||
const res = await fixture.fetch('/react-syntax-error');
|
||||
|
||||
expect(res.status).to.equal(500);
|
||||
|
||||
const body = await res.text();
|
||||
|
||||
expect(body).to.include('Syntax error');
|
||||
});
|
||||
|
||||
it('runtime error', async () => {
|
||||
const res = await fixture.fetch('/react-runtime-error');
|
||||
|
||||
expect(res.status).to.equal(500);
|
||||
|
||||
const body = await res.text();
|
||||
|
||||
expect(body).to.include('Error: ReactRuntimeError');
|
||||
});
|
||||
});
|
||||
|
@ -107,15 +139,21 @@ describe('Error display', () => {
|
|||
describe('Solid', () => {
|
||||
it('syntax error', async () => {
|
||||
const res = await fixture.fetch('/solid-syntax-error');
|
||||
|
||||
expect(res.status).to.equal(500);
|
||||
|
||||
const body = await res.text();
|
||||
|
||||
expect(body).to.include('Syntax error');
|
||||
});
|
||||
|
||||
it('runtime error', async () => {
|
||||
const res = await fixture.fetch('/solid-runtime-error');
|
||||
|
||||
expect(res.status).to.equal(500);
|
||||
|
||||
const body = await res.text();
|
||||
|
||||
expect(body).to.include('Error: SolidRuntimeError');
|
||||
});
|
||||
});
|
||||
|
@ -123,15 +161,21 @@ describe('Error display', () => {
|
|||
describe('Svelte', () => {
|
||||
it('syntax error', async () => {
|
||||
const res = await fixture.fetch('/svelte-syntax-error');
|
||||
|
||||
expect(res.status).to.equal(500);
|
||||
|
||||
const body = await res.text();
|
||||
|
||||
expect(body).to.include('Internal Error');
|
||||
});
|
||||
|
||||
it('runtime error', async () => {
|
||||
const res = await fixture.fetch('/svelte-runtime-error');
|
||||
|
||||
expect(res.status).to.equal(500);
|
||||
|
||||
const body = await res.text();
|
||||
|
||||
expect(body).to.include('Error: SvelteRuntimeError');
|
||||
});
|
||||
});
|
||||
|
@ -140,14 +184,18 @@ describe('Error display', () => {
|
|||
it('syntax error', async () => {
|
||||
const res = await fixture.fetch('/vue-syntax-error');
|
||||
const body = await res.text();
|
||||
|
||||
expect(res.status).to.equal(500);
|
||||
expect(body).to.include('Parse failure');
|
||||
});
|
||||
|
||||
it('runtime error', async () => {
|
||||
const res = await fixture.fetch('/vue-runtime-error');
|
||||
|
||||
expect(res.status).to.equal(500);
|
||||
|
||||
const body = await res.text();
|
||||
|
||||
expect(body).to.match(/Cannot read.*undefined/); // note: error differs slightly between Node versions
|
||||
});
|
||||
});
|
||||
|
|
|
@ -45,8 +45,9 @@ describe('Svelte component', () => {
|
|||
|
||||
for (const script of $('script').toArray()) {
|
||||
const { src } = script.attribs;
|
||||
|
||||
if (!src) continue;
|
||||
console.log({ src });
|
||||
|
||||
expect((await fixture.fetch(src)).status, `404: ${src}`).to.equal(200);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -34,7 +34,6 @@ async function fetch(url) {
|
|||
|
||||
function assert(a, b, message) {
|
||||
if (a !== b) throw new Error(red(`✘ ${message}`));
|
||||
// console.log(green(`✔ ${message}`)); // don’t show successes
|
||||
}
|
||||
|
||||
async function testTemplate(template) {
|
||||
|
|
Loading…
Reference in a new issue