Skip to content

Commit

Permalink
use toThrowError
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich Harris committed May 13, 2023
1 parent 140bd4f commit 8706091
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions packages/kit/src/runtime/server/page/load_data.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert, test } from 'vitest';
import { assert, expect, test } from 'vitest';
import { create_universal_fetch } from './load_data.js';

/**
Expand Down Expand Up @@ -47,20 +47,13 @@ test('succeeds when acao header present on cors', async () => {

test('errors when no acao header present on cors', async () => {
const fetch = create_fetch({});
try {

expect(async () => {
const response = await fetch('https://domain-b.com');
await response.text();
throw new Error('should have thrown cors error');
} catch (e) {
if (!(e instanceof Error)) {
throw new Error(`Expected an Error to be thrown but received ${typeof e}`);
}
assert.isTrue(
e.message.includes(
"CORS error: No 'Access-Control-Allow-Origin' header is present on the requested resource"
)
);
}
}).rejects.toThrowError(
"CORS error: No 'Access-Control-Allow-Origin' header is present on the requested resource"
);
});

test('errors when trying to access non-serialized request headers on the server', async () => {
Expand Down

0 comments on commit 8706091

Please sign in to comment.