diff --git a/packages/kit/src/runtime/server/page/load_data.spec.js b/packages/kit/src/runtime/server/page/load_data.spec.js index 2f7c3a1e5903..88785b4a7b98 100644 --- a/packages/kit/src/runtime/server/page/load_data.spec.js +++ b/packages/kit/src/runtime/server/page/load_data.spec.js @@ -1,4 +1,4 @@ -import { assert, test } from 'vitest'; +import { assert, expect, test } from 'vitest'; import { create_universal_fetch } from './load_data.js'; /** @@ -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 () => {