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