summaryrefslogtreecommitdiff
path: root/packages/integrations/node/test/errors.test.js
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@skypack.dev> 2023-05-01 10:08:18 -0400
committerGravatar GitHub <noreply@github.com> 2023-05-01 10:08:18 -0400
commit94dc1a15d0067615083dbb0cd4e3f0462cf7cb24 (patch)
treeeb65f6acf0bb0f7cdcb11eaad48ffe87eed24dad /packages/integrations/node/test/errors.test.js
parent1edc289839f57469f24c59d62dee96132d530528 (diff)
downloadastro-94dc1a15d0067615083dbb0cd4e3f0462cf7cb24.tar.gz
astro-94dc1a15d0067615083dbb0cd4e3f0462cf7cb24.tar.zst
astro-94dc1a15d0067615083dbb0cd4e3f0462cf7cb24.zip
Catch errors that occur within the stream in the Node adapter (#6935)
* Catch errors that occur within the stream in the Node adapter * Adding a changeset * Better error message on completely uncaught errors within the stream * Update test
Diffstat (limited to 'packages/integrations/node/test/errors.test.js')
-rw-r--r--packages/integrations/node/test/errors.test.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/packages/integrations/node/test/errors.test.js b/packages/integrations/node/test/errors.test.js
new file mode 100644
index 000000000..6bb93023a
--- /dev/null
+++ b/packages/integrations/node/test/errors.test.js
@@ -0,0 +1,33 @@
+import nodejs from '../dist/index.js';
+import { loadFixture } from './test-utils.js';
+import { expect } from 'chai';
+import * as cheerio from 'cheerio';
+
+describe('Errors', () => {
+ let fixture;
+ before(async () => {
+ fixture = await loadFixture({
+ root: './fixtures/errors/',
+ output: 'server',
+ adapter: nodejs({ mode: 'standalone' }),
+ });
+ await fixture.build();
+ });
+ describe('Within the stream', async () => {
+ let devPreview;
+
+ before(async () => {
+ devPreview = await fixture.preview();
+ });
+ after(async () => {
+ await devPreview.stop();
+ });
+ it('when mode is standalone', async () => {
+ const res = await fixture.fetch('/in-stream');
+ const html = await res.text();
+ const $ = cheerio.load(html);
+
+ expect($('p').text().trim()).to.equal('Internal server error');
+ });
+ });
+});