summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Fred K. Schott <fkschott@gmail.com> 2021-07-20 12:22:29 -0700
committerGravatar GitHub <noreply@github.com> 2021-07-20 12:22:29 -0700
commit7ccfc7c03ccbc32eb08d2a1664987227a270261c (patch)
tree9cd888879869120d4497a8dd05e7ac5dadb8c452
parent268186c27d436dd4fe6a330af8790ceeaeb6492c (diff)
downloadastro-7ccfc7c03ccbc32eb08d2a1664987227a270261c.tar.gz
astro-7ccfc7c03ccbc32eb08d2a1664987227a270261c.tar.zst
astro-7ccfc7c03ccbc32eb08d2a1664987227a270261c.zip
move throws to assertions (#763)
-rw-r--r--packages/astro/test/astro-attrs.test.js4
-rw-r--r--packages/astro/test/astro-basic.test.js2
-rw-r--r--packages/astro/test/astro-children.test.js9
-rw-r--r--packages/astro/test/astro-collection.test.js14
-rw-r--r--packages/astro/test/astro-components.test.js2
-rw-r--r--packages/astro/test/astro-doctype.test.js8
-rw-r--r--packages/astro/test/astro-dynamic.test.js4
-rw-r--r--packages/astro/test/astro-expr.test.js14
-rw-r--r--packages/astro/test/astro-fallback.test.js2
-rw-r--r--packages/astro/test/astro-global.test.js4
-rw-r--r--packages/astro/test/astro-hmr.test.js8
-rw-r--r--packages/astro/test/astro-markdown-plugins.test.js4
-rw-r--r--packages/astro/test/astro-markdown.test.js14
-rw-r--r--packages/astro/test/astro-slots.test.js12
-rw-r--r--packages/astro/test/astro-styles-ssr.test.js5
-rw-r--r--packages/astro/test/benchmark/benchmark.js4
-rw-r--r--packages/astro/test/builtins-polyfillnode.test.js2
-rw-r--r--packages/astro/test/builtins.test.js2
-rw-r--r--packages/astro/test/custom-elements.test.js12
-rw-r--r--packages/astro/test/lit-element.test.js4
-rw-r--r--packages/astro/test/no-head-el.test.js4
-rw-r--r--packages/astro/test/plain-markdown.test.js2
-rw-r--r--packages/astro/test/preact-component.test.js8
-rw-r--r--packages/astro/test/react-component.test.js6
24 files changed, 72 insertions, 78 deletions
diff --git a/packages/astro/test/astro-attrs.test.js b/packages/astro/test/astro-attrs.test.js
index 3bc296ab9..26371aeab 100644
--- a/packages/astro/test/astro-attrs.test.js
+++ b/packages/astro/test/astro-attrs.test.js
@@ -9,7 +9,7 @@ setup(Attributes, './fixtures/astro-attrs');
Attributes('Passes attributes to elements as expected', async ({ runtime }) => {
const result = await runtime.load('/');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
@@ -27,7 +27,7 @@ Attributes('Passes attributes to elements as expected', async ({ runtime }) => {
Attributes('Passes boolean attributes to components as expected', async ({ runtime }) => {
const result = await runtime.load('/component');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('#true').attr('attr'), 'attr-true');
diff --git a/packages/astro/test/astro-basic.test.js b/packages/astro/test/astro-basic.test.js
index 38f62085e..87dcc84f4 100644
--- a/packages/astro/test/astro-basic.test.js
+++ b/packages/astro/test/astro-basic.test.js
@@ -14,7 +14,7 @@ setupBuild(Basics, './fixtures/astro-basic');
Basics('Can load page', async ({ runtime }) => {
const result = await runtime.load('/');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
diff --git a/packages/astro/test/astro-children.test.js b/packages/astro/test/astro-children.test.js
index f986887de..9bacbd217 100644
--- a/packages/astro/test/astro-children.test.js
+++ b/packages/astro/test/astro-children.test.js
@@ -10,7 +10,7 @@ setupBuild(ComponentChildren, './fixtures/astro-children');
ComponentChildren('Passes string children to framework components', async ({ runtime }) => {
let result = await runtime.load('/strings');
- if (result.error) throw new Error(result);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
@@ -26,7 +26,7 @@ ComponentChildren('Passes string children to framework components', async ({ run
ComponentChildren('Passes markup children to framework components', async ({ runtime }) => {
let result = await runtime.load('/markup');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
@@ -42,10 +42,7 @@ ComponentChildren('Passes markup children to framework components', async ({ run
ComponentChildren('Passes multiple children to framework components', async ({ runtime }) => {
let result = await runtime.load('/multiple');
- if (result.error) {
- console.log(result);
- throw new Error(result.error);
- }
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
diff --git a/packages/astro/test/astro-collection.test.js b/packages/astro/test/astro-collection.test.js
index 4f685b355..16cd45b99 100644
--- a/packages/astro/test/astro-collection.test.js
+++ b/packages/astro/test/astro-collection.test.js
@@ -9,7 +9,7 @@ setup(Collections, './fixtures/astro-collection');
Collections('shallow selector (*.md)', async ({ runtime }) => {
const result = await runtime.load('/shallow');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
const urls = [
...$('#posts a').map(function () {
@@ -22,7 +22,7 @@ Collections('shallow selector (*.md)', async ({ runtime }) => {
Collections('deep selector (**/*.md)', async ({ runtime }) => {
const result = await runtime.load('/nested');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
const urls = [
...$('#posts a').map(function () {
@@ -34,7 +34,7 @@ Collections('deep selector (**/*.md)', async ({ runtime }) => {
Collections('generates pagination successfully', async ({ runtime }) => {
const result = await runtime.load('/paginated');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
const prev = $('#prev-page');
const next = $('#next-page');
@@ -44,7 +44,7 @@ Collections('generates pagination successfully', async ({ runtime }) => {
Collections('can load remote data', async ({ runtime }) => {
const result = await runtime.load('/remote');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
const PACKAGES_TO_TEST = ['canvas-confetti', 'preact', 'svelte'];
@@ -72,7 +72,7 @@ Collections('generates pages grouped by author', async ({ runtime }) => {
for (const { id, posts } of AUTHORS_TO_TEST) {
const result = await runtime.load(`/grouped/${id}`);
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.ok($(`#${id}`).length);
@@ -101,7 +101,7 @@ Collections('generates individual pages from a collection', async ({ runtime })
for (const { slug, title } of PAGES_TO_TEST) {
const result = await runtime.load(`/individual/${slug}`);
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.ok($(`#${slug}`).length);
@@ -111,7 +111,7 @@ Collections('generates individual pages from a collection', async ({ runtime })
Collections('matches collection filename exactly', async ({ runtime }) => {
const result = await runtime.load('/individuals');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.ok($('#posts').length);
diff --git a/packages/astro/test/astro-components.test.js b/packages/astro/test/astro-components.test.js
index 0d9bd7ac0..cea0b426f 100644
--- a/packages/astro/test/astro-components.test.js
+++ b/packages/astro/test/astro-components.test.js
@@ -9,7 +9,7 @@ setup(Components, './fixtures/astro-components');
Components('Astro components are able to render framework components', async ({ runtime }) => {
let result = await runtime.load('/');
- if (result.error) throw new Error(result);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
diff --git a/packages/astro/test/astro-doctype.test.js b/packages/astro/test/astro-doctype.test.js
index d5b863992..86a7c57a6 100644
--- a/packages/astro/test/astro-doctype.test.js
+++ b/packages/astro/test/astro-doctype.test.js
@@ -34,7 +34,7 @@ DType('No errors creating a runtime', () => {
DType('Automatically prepends the standards mode doctype', async () => {
const result = await runtime.load('/prepend');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const html = result.contents.toString('utf-8');
assert.ok(html.startsWith('<!doctype html>'), 'Doctype always included');
@@ -42,7 +42,7 @@ DType('Automatically prepends the standards mode doctype', async () => {
DType('No attributes added when doctype is provided by user', async () => {
const result = await runtime.load('/provided');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const html = result.contents.toString('utf-8');
assert.ok(html.startsWith('<!doctype html>'), 'Doctype always included');
@@ -50,7 +50,7 @@ DType('No attributes added when doctype is provided by user', async () => {
DType.skip('Preserves user provided doctype', async () => {
const result = await runtime.load('/preserve');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const html = result.contents.toString('utf-8');
assert.ok(html.startsWith('<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'), 'Doctype included was preserved');
@@ -58,7 +58,7 @@ DType.skip('Preserves user provided doctype', async () => {
DType('User provided doctype is case insensitive', async () => {
const result = await runtime.load('/capital');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const html = result.contents.toString('utf-8');
assert.ok(html.startsWith('<!DOCTYPE html>'), 'Doctype left alone');
diff --git a/packages/astro/test/astro-dynamic.test.js b/packages/astro/test/astro-dynamic.test.js
index 9decd539c..62ecccbfc 100644
--- a/packages/astro/test/astro-dynamic.test.js
+++ b/packages/astro/test/astro-dynamic.test.js
@@ -9,7 +9,7 @@ setupBuild(DynamicComponents, './fixtures/astro-dynamic');
DynamicComponents('Loads client-only packages', async ({ runtime }) => {
let result = await runtime.load('/');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
// Grab the react-dom import
const exp = /import\("(.+?)"\)/g;
@@ -28,7 +28,7 @@ DynamicComponents('Loads client-only packages', async ({ runtime }) => {
DynamicComponents('Loads pages using client:media hydrator', async ({ runtime }) => {
let result = await runtime.load('/media');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
let html = result.contents;
assert.ok(html.includes(`value: "(max-width: 700px)"`), 'static value rendered');
diff --git a/packages/astro/test/astro-expr.test.js b/packages/astro/test/astro-expr.test.js
index 505bf2845..10d1909a4 100644
--- a/packages/astro/test/astro-expr.test.js
+++ b/packages/astro/test/astro-expr.test.js
@@ -9,7 +9,7 @@ setup(Expressions, './fixtures/astro-expr');
Expressions('Can load page', async ({ runtime }) => {
const result = await runtime.load('/');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
@@ -20,7 +20,7 @@ Expressions('Can load page', async ({ runtime }) => {
Expressions('Ignores characters inside of strings', async ({ runtime }) => {
const result = await runtime.load('/strings');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
@@ -31,7 +31,7 @@ Expressions('Ignores characters inside of strings', async ({ runtime }) => {
Expressions('Ignores characters inside of line comments', async ({ runtime }) => {
const result = await runtime.load('/line-comments');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
@@ -42,7 +42,7 @@ Expressions('Ignores characters inside of line comments', async ({ runtime }) =>
Expressions('Ignores characters inside of multiline comments', async ({ runtime }) => {
const result = await runtime.load('/multiline-comments');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
@@ -53,14 +53,14 @@ Expressions('Ignores characters inside of multiline comments', async ({ runtime
Expressions('Allows multiple JSX children in mustache', async ({ runtime }) => {
const result = await runtime.load('/multiple-children');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
assert.ok(result.contents.includes('#f') && !result.contents.includes('#t'));
});
Expressions('Allows <> Fragments in expressions', async ({ runtime }) => {
const result = await runtime.load('/multiple-children');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('#fragment').children().length, 3);
@@ -71,7 +71,7 @@ Expressions('Allows <> Fragments in expressions', async ({ runtime }) => {
Expressions('Does not render falsy values using &&', async ({ runtime }) => {
const result = await runtime.load('/falsy');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
diff --git a/packages/astro/test/astro-fallback.test.js b/packages/astro/test/astro-fallback.test.js
index a4edec371..6079faa05 100644
--- a/packages/astro/test/astro-fallback.test.js
+++ b/packages/astro/test/astro-fallback.test.js
@@ -9,7 +9,7 @@ setup(Fallback, './fixtures/astro-fallback');
Fallback('Shows static content', async (context) => {
const result = await context.runtime.load('/');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('#fallback').text(), 'static');
diff --git a/packages/astro/test/astro-global.test.js b/packages/astro/test/astro-global.test.js
index 5ea5c46f9..95760dc89 100644
--- a/packages/astro/test/astro-global.test.js
+++ b/packages/astro/test/astro-global.test.js
@@ -9,7 +9,7 @@ setup(Global, './fixtures/astro-global');
Global('Astro.request.url', async (context) => {
const result = await context.runtime.load('/');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('#pathname').text(), '/');
@@ -34,7 +34,7 @@ Global('Astro.request.canonicalURL', async (context) => {
Global('Astro.site', async (context) => {
const result = await context.runtime.load('/');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('#site').attr('href'), 'https://mysite.dev');
diff --git a/packages/astro/test/astro-hmr.test.js b/packages/astro/test/astro-hmr.test.js
index 330ed1af8..3d91ffaa8 100644
--- a/packages/astro/test/astro-hmr.test.js
+++ b/packages/astro/test/astro-hmr.test.js
@@ -13,7 +13,7 @@ setup(HMR, './fixtures/astro-hmr', {
HMR('Honors the user provided port', async ({ runtime }) => {
const result = await runtime.load('/');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const html = result.contents;
assert.ok(/window\.HMR_WEBSOCKET_PORT = 5555/.test(html), "Uses the user's websocket port");
@@ -21,7 +21,7 @@ HMR('Honors the user provided port', async ({ runtime }) => {
HMR('Does not override script added by the user', async ({ runtime }) => {
const result = await runtime.load('/manual');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const html = result.contents;
@@ -31,7 +31,7 @@ HMR('Does not override script added by the user', async ({ runtime }) => {
HMR('Adds script to static pages too', async ({ runtime }) => {
const result = await runtime.load('/static');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const html = result.contents;
const $ = doc(html);
@@ -41,7 +41,7 @@ HMR('Adds script to static pages too', async ({ runtime }) => {
HMR("Adds script to pages even if there aren't any elements in the template", async ({ runtime }) => {
const result = await runtime.load('/no-elements');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const html = result.contents;
const $ = doc(html);
diff --git a/packages/astro/test/astro-markdown-plugins.test.js b/packages/astro/test/astro-markdown-plugins.test.js
index a5284cc4b..736e38cd6 100644
--- a/packages/astro/test/astro-markdown-plugins.test.js
+++ b/packages/astro/test/astro-markdown-plugins.test.js
@@ -10,7 +10,7 @@ setupBuild(MarkdownPlugin, './fixtures/astro-markdown-plugins');
MarkdownPlugin('Can render markdown with plugins', async ({ runtime }) => {
const result = await runtime.load('/');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('.toc').length, 1, 'Added a TOC');
@@ -19,7 +19,7 @@ MarkdownPlugin('Can render markdown with plugins', async ({ runtime }) => {
MarkdownPlugin('Can render Astro <Markdown> with plugins', async ({ runtime }) => {
const result = await runtime.load('/astro');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('.toc').length, 1, 'Added a TOC');
diff --git a/packages/astro/test/astro-markdown.test.js b/packages/astro/test/astro-markdown.test.js
index 3517c88f1..d696a1649 100644
--- a/packages/astro/test/astro-markdown.test.js
+++ b/packages/astro/test/astro-markdown.test.js
@@ -10,7 +10,7 @@ setupBuild(Markdown, './fixtures/astro-markdown');
Markdown('Can load markdown pages with Astro', async ({ runtime }) => {
const result = await runtime.load('/post');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.ok($('#first').length, 'There is a div added in markdown');
@@ -19,7 +19,7 @@ Markdown('Can load markdown pages with Astro', async ({ runtime }) => {
Markdown('Can load more complex jsxy stuff', async ({ runtime }) => {
const result = await runtime.load('/complex');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
const $el = $('#test');
@@ -28,7 +28,7 @@ Markdown('Can load more complex jsxy stuff', async ({ runtime }) => {
Markdown('Runs code blocks through syntax highlighter', async ({ runtime }) => {
const result = await runtime.load('/code');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
const $el = $('code span');
@@ -47,7 +47,7 @@ Markdown('Bundles client-side JS for prod', async (context) => {
Markdown('Renders correctly when deeply nested on a page', async ({ runtime }) => {
const result = await runtime.load('/deep');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('#deep').children().length, 3, 'Rendered all children');
@@ -62,7 +62,7 @@ Markdown('Renders correctly when deeply nested on a page', async ({ runtime }) =
Markdown('Renders recursively', async ({ runtime }) => {
const result = await runtime.load('/recursive');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('.a > h1').text(), 'A', 'Rendered title .a correctly');
@@ -72,7 +72,7 @@ Markdown('Renders recursively', async ({ runtime }) => {
Markdown('Renders dynamic content though the content attribute', async ({ runtime }) => {
const result = await runtime.load('/external');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('#outer').length, 1, 'Rendered markdown content');
@@ -82,7 +82,7 @@ Markdown('Renders dynamic content though the content attribute', async ({ runtim
Markdown('Does not close parent early when using content attribute (#494)', async ({ runtime }) => {
const result = await runtime.load('/close');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('#target').children().length, 2, '<Markdown content /> closed div#target early');
diff --git a/packages/astro/test/astro-slots.test.js b/packages/astro/test/astro-slots.test.js
index 69944a437..72b53c3e6 100644
--- a/packages/astro/test/astro-slots.test.js
+++ b/packages/astro/test/astro-slots.test.js
@@ -14,7 +14,7 @@ setupBuild(Slots, './fixtures/astro-slots');
Slots('Basic named slots work', async ({ runtime }) => {
const result = await runtime.load('/');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
@@ -26,7 +26,7 @@ Slots('Basic named slots work', async ({ runtime }) => {
Slots('Dynamic named slots work', async ({ runtime }) => {
const result = await runtime.load('/dynamic');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
@@ -38,7 +38,7 @@ Slots('Dynamic named slots work', async ({ runtime }) => {
Slots('Slots render fallback content by default', async ({ runtime }) => {
const result = await runtime.load('/fallback');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
@@ -47,7 +47,7 @@ Slots('Slots render fallback content by default', async ({ runtime }) => {
Slots('Slots override fallback content', async ({ runtime }) => {
const result = await runtime.load('/fallback-override');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
@@ -56,7 +56,7 @@ Slots('Slots override fallback content', async ({ runtime }) => {
Slots('Slots work with multiple elements', async ({ runtime }) => {
const result = await runtime.load('/multiple');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
@@ -65,7 +65,7 @@ Slots('Slots work with multiple elements', async ({ runtime }) => {
Slots('Slots work on Components', async ({ runtime }) => {
const result = await runtime.load('/component');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
diff --git a/packages/astro/test/astro-styles-ssr.test.js b/packages/astro/test/astro-styles-ssr.test.js
index 3097d3970..e83620c8d 100644
--- a/packages/astro/test/astro-styles-ssr.test.js
+++ b/packages/astro/test/astro-styles-ssr.test.js
@@ -116,9 +116,8 @@ StylesSSR('Astro scoped styles', async ({ runtime }) => {
scopedClass = match;
return match;
});
-
- if (!scopedClass) throw new Error(`Astro component missing scoped class`);
-
+
+ assert.ok(scopedClass, `Astro component missing scoped class`);
assert.match(el1.attr('class'), `blue ${scopedClass}`);
assert.match(el2.attr('class'), `visible ${scopedClass}`);
diff --git a/packages/astro/test/benchmark/benchmark.js b/packages/astro/test/benchmark/benchmark.js
index 76d30e935..afeabe986 100644
--- a/packages/astro/test/benchmark/benchmark.js
+++ b/packages/astro/test/benchmark/benchmark.js
@@ -43,9 +43,7 @@ export class Benchmark {
}
check() {
- if (this.withinPreviousRuns === false) {
- throw new Error(`${this.options.name} ran too slowly`);
- }
+ assert.ok(this.withinPreviousRuns !== false, `${this.options.name} ran too slowly`);
}
async save() {
diff --git a/packages/astro/test/builtins-polyfillnode.test.js b/packages/astro/test/builtins-polyfillnode.test.js
index 8fef5e8e9..972e5766b 100644
--- a/packages/astro/test/builtins-polyfillnode.test.js
+++ b/packages/astro/test/builtins-polyfillnode.test.js
@@ -9,7 +9,7 @@ setup(Builtins, './fixtures/builtins-polyfillnode');
Builtins('Doesnt alias to node: prefix', async ({ runtime }) => {
const result = await runtime.load('/');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
diff --git a/packages/astro/test/builtins.test.js b/packages/astro/test/builtins.test.js
index e54016fbd..625551311 100644
--- a/packages/astro/test/builtins.test.js
+++ b/packages/astro/test/builtins.test.js
@@ -13,7 +13,7 @@ Builtins('Can be used with the node: prefix', async ({ runtime }) => {
return;
}
const result = await runtime.load('/');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
diff --git a/packages/astro/test/custom-elements.test.js b/packages/astro/test/custom-elements.test.js
index 22a16d9aa..1b1db6a11 100644
--- a/packages/astro/test/custom-elements.test.js
+++ b/packages/astro/test/custom-elements.test.js
@@ -9,7 +9,7 @@ setup(CustomElements, './fixtures/custom-elements');
CustomElements('Work as constructors', async ({ runtime }) => {
const result = await runtime.load('/ctr');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('my-element').length, 1, 'Element rendered');
@@ -18,7 +18,7 @@ CustomElements('Work as constructors', async ({ runtime }) => {
CustomElements('Works with exported tagName', async ({ runtime }) => {
const result = await runtime.load('/');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('my-element').length, 1, 'Element rendered');
@@ -27,7 +27,7 @@ CustomElements('Works with exported tagName', async ({ runtime }) => {
CustomElements('Hydration works with exported tagName', async ({ runtime }) => {
const result = await runtime.load('/load');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const html = result.contents;
const $ = doc(html);
@@ -42,7 +42,7 @@ CustomElements('Hydration works with exported tagName', async ({ runtime }) => {
CustomElements('Polyfills are added before the hydration script', async ({ runtime }) => {
const result = await runtime.load('/load');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const html = result.contents;
const $ = doc(html);
@@ -54,7 +54,7 @@ CustomElements('Polyfills are added before the hydration script', async ({ runti
CustomElements('Polyfills are added even if not hydrating', async ({ runtime }) => {
const result = await runtime.load('/');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const html = result.contents;
const $ = doc(html);
@@ -66,7 +66,7 @@ CustomElements('Polyfills are added even if not hydrating', async ({ runtime })
CustomElements('Custom elements not claimed by renderer are rendered as regular HTML', async ({ runtime }) => {
const result = await runtime.load('/nossr');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('client-element').length, 1, 'Rendered the client-only element');
diff --git a/packages/astro/test/lit-element.test.js b/packages/astro/test/lit-element.test.js
index ef1d5ebae..6f44d055e 100644
--- a/packages/astro/test/lit-element.test.js
+++ b/packages/astro/test/lit-element.test.js
@@ -13,7 +13,7 @@ LitElement('Renders a custom element by tag name', async ({ runtime }) => {
return;
}
const result = await runtime.load('/');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
@@ -24,7 +24,7 @@ LitElement('Renders a custom element by tag name', async ({ runtime }) => {
// Skipped because not supported by Lit
LitElement.skip('Renders a custom element by the constructor', async ({ runtime }) => {
const result = await runtime.load('/ctr');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
diff --git a/packages/astro/test/no-head-el.test.js b/packages/astro/test/no-head-el.test.js
index 4e372288f..4b808591f 100644
--- a/packages/astro/test/no-head-el.test.js
+++ b/packages/astro/test/no-head-el.test.js
@@ -13,7 +13,7 @@ setup(NoHeadEl, './fixtures/no-head-el', {
NoHeadEl('Places style and scripts before the first non-head element', async ({ runtime }) => {
const result = await runtime.load('/');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const html = result.contents;
const $ = doc(html);
@@ -27,7 +27,7 @@ NoHeadEl('Places style and scripts before the first non-head element', async ({
NoHeadEl('Injects HMR script even when there are no elements on the page', async ({ runtime }) => {
const result = await runtime.load('/no-elements');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const html = result.contents;
const $ = doc(html);
diff --git a/packages/astro/test/plain-markdown.test.js b/packages/astro/test/plain-markdown.test.js
index 3adc904f5..7a2852af9 100644
--- a/packages/astro/test/plain-markdown.test.js
+++ b/packages/astro/test/plain-markdown.test.js
@@ -22,7 +22,7 @@ Markdown('Can load a simple markdown page with Astro', async ({ runtime }) => {
Markdown('Can load a realworld markdown page with Astro', async ({ runtime }) => {
const result = await runtime.load('/realworld');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
assert.equal(result.statusCode, 200);
const $ = doc(result.contents);
diff --git a/packages/astro/test/preact-component.test.js b/packages/astro/test/preact-component.test.js
index 135e1a31e..3b3a37dfc 100644
--- a/packages/astro/test/preact-component.test.js
+++ b/packages/astro/test/preact-component.test.js
@@ -9,7 +9,7 @@ setup(PreactComponent, './fixtures/preact-component');
PreactComponent('Can load class component', async ({ runtime }) => {
const result = await runtime.load('/class');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('#class-component').length, 1, 'Can use class components');
@@ -17,7 +17,7 @@ PreactComponent('Can load class component', async ({ runtime }) => {
PreactComponent('Can load function component', async ({ runtime }) => {
const result = await runtime.load('/fn');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('#fn-component').length, 1, 'Can use function components');
@@ -26,7 +26,7 @@ PreactComponent('Can load function component', async ({ runtime }) => {
PreactComponent('Can use hooks', async ({ runtime }) => {
const result = await runtime.load('/hooks');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('#world').length, 1);
@@ -34,7 +34,7 @@ PreactComponent('Can use hooks', async ({ runtime }) => {
PreactComponent('Can export a Fragment', async ({ runtime }) => {
const result = await runtime.load('/frag');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('body').children().length, 0, "nothing rendered but it didn't throw.");
diff --git a/packages/astro/test/react-component.test.js b/packages/astro/test/react-component.test.js
index aa196fdfb..48c985be1 100644
--- a/packages/astro/test/react-component.test.js
+++ b/packages/astro/test/react-component.test.js
@@ -35,7 +35,7 @@ React('No error creating the runtime', () => {
React('Can load React', async () => {
const result = await runtime.load('/');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('#react-h2').text(), 'Hello world!');
@@ -45,7 +45,7 @@ React('Can load React', async () => {
React('Includes reactroot on hydrating components', async () => {
const result = await runtime.load('/');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
const div = $('#research');
@@ -66,7 +66,7 @@ React('Throws helpful error message on window SSR', async () => {
React('Can load Vue', async () => {
const result = await runtime.load('/');
- if (result.error) throw new Error(result.error);
+ assert.ok(!result.error, `build error: ${result.error}`);
const $ = doc(result.contents);
assert.equal($('#vue-h2').text(), 'Hasta la vista, baby');