diff --git a/packages/astro/test/data-collections.test.js b/packages/astro/test/data-collections.nodetest.js similarity index 58% rename from packages/astro/test/data-collections.test.js rename to packages/astro/test/data-collections.nodetest.js index e30f49ac2a..1e47b03f95 100644 --- a/packages/astro/test/data-collections.test.js +++ b/packages/astro/test/data-collections.nodetest.js @@ -1,4 +1,5 @@ -import { expect } from 'chai'; +import assert from 'node:assert/strict'; +import { describe, before, it } from 'node:test'; import { loadFixture } from './test-utils.js'; const authorIds = ['Ben Holmes', 'Fred K Schott', 'Nate Moore']; @@ -19,21 +20,21 @@ describe('Content Collections - data collections', () => { }); it('Returns', async () => { - expect(Array.isArray(json)).to.be.true; - expect(json.length).to.equal(3); + assert.equal(Array.isArray(json), true); + assert.equal(json.length, 3); }); it('Generates correct ids', async () => { const ids = json.map((item) => item.id).sort(); - expect(ids).to.deep.equal(['Ben Holmes', 'Fred K Schott', 'Nate Moore']); + assert.deepEqual(ids, ['Ben Holmes', 'Fred K Schott', 'Nate Moore']); }); it('Generates correct data', async () => { const names = json.map((item) => item.data.name); - expect(names).to.deep.equal(['Ben J Holmes', 'Fred K Schott', 'Nate Something Moore']); + assert.deepEqual(names, ['Ben J Holmes', 'Fred K Schott', 'Nate Something Moore']); const twitterUrls = json.map((item) => item.data.twitter); - expect(twitterUrls).to.deep.equal([ + assert.deepEqual(twitterUrls, [ 'https://twitter.com/bholmesdev', 'https://twitter.com/FredKSchott', 'https://twitter.com/n_moore', @@ -48,7 +49,7 @@ describe('Content Collections - data collections', () => { json = JSON.parse(rawJson); }); it('Grabs the item by the base file name', () => { - expect(json.id).to.equal('en'); + assert.equal(json.id, 'en'); }); }); @@ -61,27 +62,27 @@ describe('Content Collections - data collections', () => { }); it(`Returns ${authorId}`, async () => { - expect(json).to.haveOwnProperty('id'); - expect(json.id).to.equal(authorId); + assert.equal(json.hasOwnProperty('id'), true); + assert.equal(json.id, authorId); }); it(`Generates correct data for ${authorId}`, async () => { - expect(json).to.haveOwnProperty('data'); - expect(json.data).to.haveOwnProperty('name'); - expect(json.data).to.haveOwnProperty('twitter'); + assert.equal(json.hasOwnProperty('data'), true); + assert.equal(json.data.hasOwnProperty('name'), true); + assert.equal(json.data.hasOwnProperty('twitter'), true); switch (authorId) { case 'Ben Holmes': - expect(json.data.name).to.equal('Ben J Holmes'); - expect(json.data.twitter).to.equal('https://twitter.com/bholmesdev'); + assert.equal(json.data.name, 'Ben J Holmes'); + assert.equal(json.data.twitter, 'https://twitter.com/bholmesdev'); break; case 'Fred K Schott': - expect(json.data.name).to.equal('Fred K Schott'); - expect(json.data.twitter).to.equal('https://twitter.com/FredKSchott'); + assert.equal(json.data.name, 'Fred K Schott'); + assert.equal(json.data.twitter, 'https://twitter.com/FredKSchott'); break; case 'Nate Moore': - expect(json.data.name).to.equal('Nate Something Moore'); - expect(json.data.twitter).to.equal('https://twitter.com/n_moore'); + assert.equal(json.data.name, 'Nate Something Moore'); + assert.equal(json.data.twitter, 'https://twitter.com/n_moore'); break; } }); @@ -96,26 +97,22 @@ describe('Content Collections - data collections', () => { }); it('Returns', async () => { - expect(Array.isArray(json)).to.be.true; - expect(json.length).to.equal(3); + assert.equal(Array.isArray(json), true); + assert.equal(json.length, 3); }); it('Generates correct ids', async () => { const ids = json.map((item) => item.id).sort(); - expect(ids).to.deep.equal(translationIds); + assert.deepEqual(ids, translationIds); }); it('Generates correct data', async () => { const sorted = json.sort((a, b) => a.id.localeCompare(b.id)); const homepageGreetings = sorted.map((item) => item.data.homepage?.greeting); - expect(homepageGreetings).to.deep.equal([ - 'Hello World!', - '¡Hola Mundo!', - 'Bonjour le monde!', - ]); + assert.deepEqual(homepageGreetings, ['Hello World!', '¡Hola Mundo!', 'Bonjour le monde!']); const homepagePreambles = sorted.map((item) => item.data.homepage?.preamble); - expect(homepagePreambles).to.deep.equal([ + assert.deepEqual(homepagePreambles, [ 'Welcome to the future of content.', 'Bienvenido al futuro del contenido.', 'Bienvenue dans le futur du contenu.', @@ -132,28 +129,28 @@ describe('Content Collections - data collections', () => { }); it(`Returns ${translationId}`, async () => { - expect(json).to.haveOwnProperty('id'); - expect(json.id).to.equal(translationId); + assert.equal(json.hasOwnProperty('id'), true); + assert.equal(json.id, translationId); }); it(`Generates correct data for ${translationId}`, async () => { - expect(json).to.haveOwnProperty('data'); - expect(json.data).to.haveOwnProperty('homepage'); - expect(json.data.homepage).to.haveOwnProperty('greeting'); - expect(json.data.homepage).to.haveOwnProperty('preamble'); + assert.equal(json.hasOwnProperty('data'), true); + assert.equal(json.data.hasOwnProperty('homepage'), true); + assert.equal(json.data.homepage.hasOwnProperty('greeting'), true); + assert.equal(json.data.homepage.hasOwnProperty('preamble'), true); switch (translationId) { case 'en': - expect(json.data.homepage.greeting).to.equal('Hello World!'); - expect(json.data.homepage.preamble).to.equal('Welcome to the future of content.'); + assert.equal(json.data.homepage.greeting, 'Hello World!'); + assert.equal(json.data.homepage.preamble, 'Welcome to the future of content.'); break; case 'es': - expect(json.data.homepage.greeting).to.equal('¡Hola Mundo!'); - expect(json.data.homepage.preamble).to.equal('Bienvenido al futuro del contenido.'); + assert.equal(json.data.homepage.greeting, '¡Hola Mundo!'); + assert.equal(json.data.homepage.preamble, 'Bienvenido al futuro del contenido.'); break; case 'fr': - expect(json.data.homepage.greeting).to.equal('Bonjour le monde!'); - expect(json.data.homepage.preamble).to.equal('Bienvenue dans le futur du contenu.'); + assert.equal(json.data.homepage.greeting, 'Bonjour le monde!'); + assert.equal(json.data.homepage.preamble, 'Bienvenue dans le futur du contenu.'); break; } }); diff --git a/packages/astro/test/debug-component.nodetest.js b/packages/astro/test/debug-component.nodetest.js new file mode 100644 index 0000000000..27cffe1a13 --- /dev/null +++ b/packages/astro/test/debug-component.nodetest.js @@ -0,0 +1,27 @@ +import assert from 'node:assert/strict'; +import { after, describe, before, it } from 'node:test'; +import { loadFixture, isMacOS } from './test-utils.js'; + +// TODO: fix this tests in macOS +if (!isMacOS) { + describe('', () => { + /** @type {import('./test-utils').Fixture} */ + let fixture; + /** @type {import('./test-utils').DevServer} */ + let devServer; + + before(async () => { + fixture = await loadFixture({ root: './fixtures/debug-component/' }); + devServer = await fixture.startDevServer(); + }); + + after(async () => { + await devServer.stop(); + }); + + it('Works in markdown pages', async () => { + const response = await fixture.fetch('/posts/first'); + assert.equal(response.status, 200); + }); + }); +} diff --git a/packages/astro/test/debug-component.test.js b/packages/astro/test/debug-component.test.js deleted file mode 100644 index 4ed81ccd01..0000000000 --- a/packages/astro/test/debug-component.test.js +++ /dev/null @@ -1,29 +0,0 @@ -import { expect } from 'chai'; -import os from 'node:os'; -import { loadFixture } from './test-utils.js'; - -// TODO: fix these tests on macOS -const isMacOS = os.platform() === 'darwin'; - -describe('', () => { - if (isMacOS) return; - - /** @type {import('./test-utils').Fixture} */ - let fixture; - /** @type {import('./test-utils').DevServer} */ - let devServer; - - before(async () => { - fixture = await loadFixture({ root: './fixtures/debug-component/' }); - devServer = await fixture.startDevServer(); - }); - - after(async () => { - await devServer.stop(); - }); - - it('Works in markdown pages', async () => { - const response = await fixture.fetch('/posts/first'); - expect(response.status).to.equal(200); - }); -}); diff --git a/packages/astro/test/dev-routing.test.js b/packages/astro/test/dev-routing.nodetest.js similarity index 76% rename from packages/astro/test/dev-routing.test.js rename to packages/astro/test/dev-routing.nodetest.js index 4feef55833..df10e0d42b 100644 --- a/packages/astro/test/dev-routing.test.js +++ b/packages/astro/test/dev-routing.nodetest.js @@ -1,4 +1,5 @@ -import { expect } from 'chai'; +import assert from 'node:assert/strict'; +import { after, describe, before, it } from 'node:test'; import { loadFixture } from './test-utils.js'; describe('Development Routing', () => { @@ -19,37 +20,37 @@ describe('Development Routing', () => { it('200 when loading /', async () => { const response = await fixture.fetch('/'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading non-UTF-8 file name', async () => { const response = await fixture.fetch('/テスト'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading include space file name', async () => { const response = await fixture.fetch('/te st'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when adding search params', async () => { const response = await fixture.fetch('/?foo=bar'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading non-root page', async () => { const response = await fixture.fetch('/another'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading dynamic route', async () => { const response = await fixture.fetch('/1'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('404 when loading invalid dynamic route', async () => { const response = await fixture.fetch('/2'); - expect(response.status).to.equal(404); + assert.equal(response.status, 404); }); }); @@ -74,22 +75,22 @@ describe('Development Routing', () => { it('200 when loading /', async () => { const response = await fixture.fetch('/'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading non-root page', async () => { const response = await fixture.fetch('/another'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading dynamic route', async () => { const response = await fixture.fetch('/1'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('404 when loading invalid dynamic route', async () => { const response = await fixture.fetch('/2'); - expect(response.status).to.equal(404); + assert.equal(response.status, 404); }); }); @@ -115,32 +116,32 @@ describe('Development Routing', () => { it('404 when loading /', async () => { const response = await fixture.fetch('/'); - expect(response.status).to.equal(404); + assert.equal(response.status, 404); }); it('200 when loading subpath root', async () => { const response = await fixture.fetch('/blog/'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading subpath root without trailing slash', async () => { const response = await fixture.fetch('/blog'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading another page with subpath used', async () => { const response = await fixture.fetch('/blog/another/'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading dynamic route', async () => { const response = await fixture.fetch('/blog/1/'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('404 when loading invalid dynamic route', async () => { const response = await fixture.fetch('/blog/2/'); - expect(response.status).to.equal(404); + assert.equal(response.status, 404); }); }); @@ -165,32 +166,32 @@ describe('Development Routing', () => { it('404 when loading /', async () => { const response = await fixture.fetch('/'); - expect(response.status).to.equal(404); + assert.equal(response.status, 404); }); it('200 when loading subpath root with trailing slash', async () => { const response = await fixture.fetch('/blog/'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading subpath root without trailing slash', async () => { const response = await fixture.fetch('/blog'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading another page with subpath used', async () => { const response = await fixture.fetch('/blog/another/'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading dynamic route', async () => { const response = await fixture.fetch('/blog/1/'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('404 when loading invalid dynamic route', async () => { const response = await fixture.fetch('/blog/2/'); - expect(response.status).to.equal(404); + assert.equal(response.status, 404); }); }); @@ -214,74 +215,74 @@ describe('Development Routing', () => { it('200 when loading /home.json', async () => { const response = await fixture.fetch('/home.json'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); const body = await response.text().then((text) => JSON.parse(text)); - expect(body.title).to.equal('home'); + assert.equal(body.title, 'home'); }); it('200 when loading /thing1.json', async () => { const response = await fixture.fetch('/thing1.json'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); const body = await response.text().then((text) => JSON.parse(text)); - expect(body.slug).to.equal('thing1'); - expect(body.title).to.equal('[slug]'); + assert.equal(body.slug, 'thing1'); + assert.equal(body.title, '[slug]'); }); it('200 when loading /thing2.json', async () => { const response = await fixture.fetch('/thing2.json'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); const body = await response.text().then((text) => JSON.parse(text)); - expect(body.slug).to.equal('thing2'); - expect(body.title).to.equal('[slug]'); + assert.equal(body.slug, 'thing2'); + assert.equal(body.title, '[slug]'); }); it('200 when loading /data/thing3.json', async () => { const response = await fixture.fetch('/data/thing3.json'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); const body = await response.text().then((text) => JSON.parse(text)); - expect(body.slug).to.equal('thing3'); - expect(body.title).to.equal('data [slug]'); + assert.equal(body.slug, 'thing3'); + assert.equal(body.title, 'data [slug]'); }); it('200 when loading /data/thing4.json', async () => { const response = await fixture.fetch('/data/thing4.json'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); const body = await response.text().then((text) => JSON.parse(text)); - expect(body.slug).to.equal('thing4'); - expect(body.title).to.equal('data [slug]'); + assert.equal(body.slug, 'thing4'); + assert.equal(body.title, 'data [slug]'); }); it('error responses are served untouched', async () => { const response = await fixture.fetch('/not-ok'); - expect(response.status).to.equal(404); - expect(response.headers.get('Content-Type')).to.equal('text/plain;charset=UTF-8'); + assert.equal(response.status, 404); + assert.equal(response.headers.get('Content-Type'), 'text/plain;charset=UTF-8'); const body = await response.text(); - expect(body).to.equal('Text from pages/not-ok.ts'); + assert.equal(body, 'Text from pages/not-ok.ts'); }); it('correct MIME type when loading /home.json (static route)', async () => { const response = await fixture.fetch('/home.json'); - expect(response.headers.get('content-type')).to.match(/application\/json/); + assert.match(response.headers.get('content-type'), /application\/json/); }); it('correct MIME type when loading /thing1.json (dynamic route)', async () => { const response = await fixture.fetch('/thing1.json'); - expect(response.headers.get('content-type')).to.match(/application\/json/); + assert.match(response.headers.get('content-type'), /application\/json/); }); it('correct MIME type when loading /images/static.svg (static image)', async () => { const response = await fixture.fetch('/images/static.svg'); - expect(response.headers.get('content-type')).to.match(/image\/svg\+xml/); + assert.match(response.headers.get('content-type'), /image\/svg\+xml/); }); it('correct MIME type when loading /images/1.svg (dynamic image)', async () => { const response = await fixture.fetch('/images/1.svg'); - expect(response.headers.get('content-type')).to.match(/image\/svg\+xml/); + assert.match(response.headers.get('content-type'), /image\/svg\+xml/); }); it('correct encoding when loading /images/hex.ts', async () => { @@ -290,7 +291,7 @@ describe('Development Routing', () => { const hex = Buffer.from(body).toString('hex', 0, 4); // Check if we have a PNG - expect(hex).to.equal('89504e47'); + assert.equal(hex, '89504e47'); }); }); @@ -317,64 +318,64 @@ describe('Development Routing', () => { it('200 when loading /index.html', async () => { const response = await fixture.fetch('/index.html'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading /', async () => { const response = await fixture.fetch('/'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading /テスト.html', async () => { const response = await fixture.fetch('/テスト.html'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading /テスト', async () => { const response = await fixture.fetch('/テスト'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading /te st.html', async () => { const response = await fixture.fetch('/te st.html'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading /te st', async () => { const response = await fixture.fetch('/te st'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading /another.html', async () => { const response = await fixture.fetch('/another.html'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading /another', async () => { const response = await fixture.fetch('/another'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading /1.html', async () => { const response = await fixture.fetch('/1.html'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading /1', async () => { const response = await fixture.fetch('/1'); - expect(response.status).to.equal(200); + assert.equal(response.status, 200); }); it('200 when loading /html-ext/1', async () => { const response = await fixture.fetch('/html-ext/1'); - expect(response.status).to.equal(200); - expect(await response.text()).includes('none: 1'); + assert.equal(response.status, 200); + assert.equal((await response.text()).includes('none: 1'), true); }); it('200 when loading /html-ext/1.html', async () => { const response = await fixture.fetch('/html-ext/1.html'); - expect(response.status).to.equal(200); - expect(await response.text()).includes('html: 1'); + assert.equal(response.status, 200); + assert.equal((await response.text()).includes('html: 1'), true); }); }); }); diff --git a/packages/astro/test/dont-delete-root.test.js b/packages/astro/test/dont-delete-root.nodetest.js similarity index 77% rename from packages/astro/test/dont-delete-root.test.js rename to packages/astro/test/dont-delete-root.nodetest.js index 5d9814aef2..3a81c16bbe 100644 --- a/packages/astro/test/dont-delete-root.test.js +++ b/packages/astro/test/dont-delete-root.nodetest.js @@ -1,4 +1,5 @@ -import { expect } from 'chai'; +import assert from 'node:assert/strict'; +import { describe, before, it } from 'node:test'; import * as fs from 'node:fs'; import { loadFixture } from './test-utils.js'; @@ -19,8 +20,8 @@ describe('outDir set to project root', async () => { }); it('Throws an error when you attempt to build', async () => { - expect(error).to.be.an.instanceOf(Error); - expect(error.message).to.match(/outDir cannot be the root folder/); + assert.equal(error instanceof Error, true); + assert.match(error.message, /outDir cannot be the root folder/); }); it('Files have not been deleted', async () => { @@ -30,7 +31,7 @@ describe('outDir set to project root', async () => { const root = new URL('./fixtures/dont-delete-me/', import.meta.url); const url = new URL('./' + rel, root); const stats = await fs.promises.stat(url); - expect(stats).to.not.be.undefined; + assert.notEqual(stats, undefined); } }); }); diff --git a/packages/astro/test/dynamic-endpoint-collision.test.js b/packages/astro/test/dynamic-endpoint-collision.nodetest.js similarity index 80% rename from packages/astro/test/dynamic-endpoint-collision.test.js rename to packages/astro/test/dynamic-endpoint-collision.nodetest.js index 329e3603bd..d3beaa76ae 100644 --- a/packages/astro/test/dynamic-endpoint-collision.test.js +++ b/packages/astro/test/dynamic-endpoint-collision.nodetest.js @@ -1,4 +1,5 @@ -import { expect } from 'chai'; +import assert from 'node:assert/strict'; +import { after, describe, before, it } from 'node:test'; import { load as cheerioLoad } from 'cheerio'; import { loadFixture } from './test-utils.js'; @@ -18,7 +19,7 @@ describe('Dynamic endpoint collision', () => { }); it('throw error when dynamic endpoint has path collision', async () => { - expect(errorMsg.name).to.eq('PrerenderDynamicEndpointPathCollide'); + assert.equal(errorMsg.name, 'PrerenderDynamicEndpointPathCollide'); }); }); @@ -41,12 +42,12 @@ describe('Dynamic endpoint collision', () => { it('throw error when dynamic endpoint has path collision', async () => { const html = await fixture.fetch('/api/catch').then((res) => res.text()); const $ = cheerioLoad(html); - expect($('title').text()).to.equal('PrerenderDynamicEndpointPathCollide'); + assert.equal($('title').text(), 'PrerenderDynamicEndpointPathCollide'); }); it("don't throw error when dynamic endpoint doesn't load the colliding path", async () => { const res = await fixture.fetch('/api/catch/one').then((r) => r.text()); - expect(res).to.equal('{"slug":"one"}'); + assert.equal(res, '{"slug":"one"}'); }); }); }); diff --git a/packages/astro/test/dynamic-route-build-file.test.js b/packages/astro/test/dynamic-route-build-file.nodetest.js similarity index 79% rename from packages/astro/test/dynamic-route-build-file.test.js rename to packages/astro/test/dynamic-route-build-file.nodetest.js index dfb7bf5de5..c251d43c71 100644 --- a/packages/astro/test/dynamic-route-build-file.test.js +++ b/packages/astro/test/dynamic-route-build-file.nodetest.js @@ -1,4 +1,5 @@ -import { expect } from 'chai'; +import assert from 'node:assert/strict'; +import { describe, before, it } from 'node:test'; import * as cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; @@ -19,6 +20,6 @@ describe('build.format=file with dynamic routes', () => { it('Outputs a slug of undefined as the index.html', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); - expect($('h1').text()).to.equal('Astro Store'); + assert.equal($('h1').text(), 'Astro Store'); }); }); diff --git a/packages/astro/test/entry-file-names.test.js b/packages/astro/test/entry-file-names.nodetest.js similarity index 72% rename from packages/astro/test/entry-file-names.test.js rename to packages/astro/test/entry-file-names.nodetest.js index 71f93876a2..b1fb2e293c 100644 --- a/packages/astro/test/entry-file-names.test.js +++ b/packages/astro/test/entry-file-names.nodetest.js @@ -1,4 +1,5 @@ -import { expect } from 'chai'; +import assert from 'node:assert/strict'; +import { describe, before, it } from 'node:test'; import * as cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; @@ -15,12 +16,12 @@ describe('vite.build.rollupOptions.entryFileNames', () => { it('Renders correctly', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); - expect($('#hello')).to.have.a.lengthOf(1); + assert.equal($('#hello').length, 1); }); it('Outputs a client module that was specified by the config', async () => { const js = await fixture.readFile('/assets/js/Hello.js'); - expect(js).to.be.a('string'); - expect(js.length).to.be.greaterThan(0); + assert.equal(typeof js === 'string', true); + assert.equal(js.length > 0, true); }); }); diff --git a/packages/astro/test/events.test.js b/packages/astro/test/events.nodetest.js similarity index 88% rename from packages/astro/test/events.test.js rename to packages/astro/test/events.nodetest.js index c0c6266d9f..e4cf3478e8 100644 --- a/packages/astro/test/events.test.js +++ b/packages/astro/test/events.nodetest.js @@ -1,4 +1,5 @@ -import { expect } from 'chai'; +import assert from 'node:assert/strict'; +import { describe, it } from 'node:test'; import { ClientAddressNotAvailable } from '../dist/core/errors/errors-data.js'; import { AstroError } from '../dist/core/errors/errors.js'; import * as events from '../dist/events/index.js'; @@ -18,7 +19,7 @@ describe('Events', () => { }, config ); - expect(payload.config.build.format).to.equal('file'); + assert.equal(payload.config.build.format, 'file'); }); it('string literal "markdown.syntaxHighlight" is included', () => { @@ -33,7 +34,7 @@ describe('Events', () => { }, config ); - expect(payload.config.markdown.syntaxHighlight).to.equal('shiki'); + assert.equal(payload.config.markdown.syntaxHighlight, 'shiki'); }); it('top-level vite keys are captured', async () => { @@ -56,7 +57,7 @@ describe('Events', () => { }, config ); - expect(Object.keys(payload.config.vite)).is.deep.equal([ + assert.deepEqual(Object.keys(payload.config.vite), [ 'css', 'base', 'mode', @@ -76,7 +77,7 @@ describe('Events', () => { }, config ); - expect(payload.config.integrations.length).to.equal(0); + assert.equal(payload.config.integrations.length, 0); }); it('only integration names are included', () => { @@ -84,7 +85,7 @@ describe('Events', () => { integrations: [{ name: 'foo' }, [{ name: 'bar' }, { name: 'baz' }]], }; const [{ payload }] = events.eventCliSession({ cliCommand: 'dev' }, config); - expect(payload.config.integrations).to.deep.equal(['foo', 'bar', 'baz']); + assert.deepEqual(payload.config.integrations, ['foo', 'bar', 'baz']); }); it('only adapter name is included', () => { @@ -92,7 +93,7 @@ describe('Events', () => { adapter: { name: 'ADAPTER_NAME' }, }; const [{ payload }] = events.eventCliSession({ cliCommand: 'dev' }, config); - expect(payload.config.adapter).to.equal('ADAPTER_NAME'); + assert.equal(payload.config.adapter, 'ADAPTER_NAME'); }); it('includes cli flags in payload', () => { @@ -113,7 +114,7 @@ describe('Events', () => { config, flags ); - expect(payload.flags).to.deep.equal([ + assert.deepEqual(payload.flags, [ 'root', 'site', 'host', @@ -132,7 +133,7 @@ describe('Events', () => { cmd: 'COMMAND_NAME', isFatal: true, }); - expect(event).to.deep.equal({ + assert.deepEqual(event, { eventName: 'ASTRO_CLI_ERROR', payload: { name: 'ZodError', @@ -155,7 +156,7 @@ describe('Events', () => { cmd: 'COMMAND_NAME', isFatal: true, }); - expect(event).to.deep.equal({ + assert.deepEqual(event, { eventName: 'ASTRO_CLI_ERROR', payload: { plugin: 'TEST PLUGIN', @@ -177,7 +178,7 @@ describe('Events', () => { isFatal: false, }); - expect(event).to.deep.equal({ + assert.deepEqual(event, { eventName: 'ASTRO_CLI_ERROR', payload: { anonymousMessageHint: @@ -196,7 +197,7 @@ describe('Events', () => { cmd: 'COMMAND_NAME', isFatal: false, }); - expect(event).to.deep.equal({ + assert.deepEqual(event, { eventName: 'ASTRO_CLI_ERROR', payload: { name: 'Error', @@ -215,7 +216,7 @@ describe('Events', () => { name: 'Error', isFatal: true, }); - expect(event.payload.anonymousMessageHint).to.equal('TEST ERROR MESSAGE'); + assert.equal(event.payload.anonymousMessageHint, 'TEST ERROR MESSAGE'); }); it('properly exclude stack traces from anonymousMessageHint', () => { @@ -231,7 +232,7 @@ describe('Events', () => { name: 'Error', isFatal: true, }); - expect(event.payload.anonymousMessageHint).to.be.undefined; + assert.equal(event.payload.anonymousMessageHint, undefined); }); }); }); diff --git a/packages/astro/test/experimental-content-collection-references.test.js b/packages/astro/test/experimental-content-collection-references.nodetest.js similarity index 67% rename from packages/astro/test/experimental-content-collection-references.test.js rename to packages/astro/test/experimental-content-collection-references.nodetest.js index b5de6a61e5..0d7ed88397 100644 --- a/packages/astro/test/experimental-content-collection-references.test.js +++ b/packages/astro/test/experimental-content-collection-references.nodetest.js @@ -1,4 +1,5 @@ -import { expect } from 'chai'; +import assert from 'node:assert/strict'; +import { describe, before, after, it } from 'node:test'; import * as cheerio from 'cheerio'; import { fixLineEndings, loadFixture } from './test-utils.js'; @@ -44,31 +45,32 @@ describe('Experimental Content Collections cache - references', () => { }); it('Returns expected keys', () => { - expect(json).to.haveOwnProperty('welcomePost'); - expect(json).to.haveOwnProperty('banner'); - expect(json).to.haveOwnProperty('author'); - expect(json).to.haveOwnProperty('relatedPosts'); + assert.equal(json.hasOwnProperty('welcomePost'), true); + assert.equal(json.hasOwnProperty('banner'), true); + assert.equal(json.hasOwnProperty('author'), true); + assert.equal(json.hasOwnProperty('relatedPosts'), true); }); it('Returns `banner` data', () => { const { banner } = json; - expect(banner).to.haveOwnProperty('data'); - expect(banner.id).to.equal('welcome'); - expect(banner.collection).to.equal('banners'); - expect(banner.data.alt).to.equal( + assert.equal(banner.hasOwnProperty('data'), true); + assert.equal(banner.id, 'welcome'); + assert.equal(banner.collection, 'banners'); + assert.equal( + banner.data.alt, 'Futuristic landscape with chrome buildings and blue skies' ); - expect(banner.data.src.width).to.equal(400); - expect(banner.data.src.height).to.equal(225); - expect(banner.data.src.format).to.equal('jpg'); - expect(banner.data.src.src.includes('the-future')).to.be.true; + assert.equal(banner.data.src.width, 400); + assert.equal(banner.data.src.height, 225); + assert.equal(banner.data.src.format, 'jpg'); + assert.equal(banner.data.src.src.includes('the-future'), true); }); it('Returns `author` data', () => { const { author } = json; - expect(author).to.haveOwnProperty('data'); - expect(author).to.deep.equal({ + assert.equal(author.hasOwnProperty('data'), true); + assert.deepEqual(author, { id: 'nate-moore', collection: 'authors', data: { @@ -80,12 +82,12 @@ describe('Experimental Content Collections cache - references', () => { it('Returns `relatedPosts` data', () => { const { relatedPosts } = json; - expect(Array.isArray(relatedPosts)).to.be.true; + assert.equal(Array.isArray(relatedPosts), true); const topLevelInfo = relatedPosts.map(({ data, body, ...meta }) => ({ ...meta, body: fixLineEndings(body).trim(), })); - expect(topLevelInfo).to.deep.equal([ + assert.deepEqual(topLevelInfo, [ { id: 'related-1.md', slug: 'related-1', @@ -100,7 +102,7 @@ describe('Experimental Content Collections cache - references', () => { }, ]); const postData = relatedPosts.map(({ data }) => data); - expect(postData).to.deep.equal([ + assert.deepEqual(postData, [ { title: 'Related post 1', banner: { id: 'welcome', collection: 'banners' }, @@ -130,32 +132,33 @@ describe('Experimental Content Collections cache - references', () => { it('Renders `banner` data', () => { const banner = $('img[data-banner]'); - expect(banner.length).to.equal(1); - expect(banner.attr('src')).to.include('the-future'); - expect(banner.attr('alt')).to.equal( + assert.equal(banner.length, 1); + assert.equal(banner.attr('src').includes('the-future'), true); + assert.equal( + banner.attr('alt'), 'Futuristic landscape with chrome buildings and blue skies' ); - expect(banner.attr('width')).to.equal('400'); - expect(banner.attr('height')).to.equal('225'); + assert.equal(banner.attr('width'), '400'); + assert.equal(banner.attr('height'), '225'); }); it('Renders `author` data', () => { const author = $('a[data-author-name]'); - expect(author.length).to.equal(1); - expect(author.attr('href')).to.equal('https://twitter.com/n_moore'); - expect(author.text()).to.equal('Nate Something Moore'); + assert.equal(author.length, 1); + assert.equal(author.attr('href'), 'https://twitter.com/n_moore'); + assert.equal(author.text(), 'Nate Something Moore'); }); it('Renders `relatedPosts` data', () => { const relatedPosts = $('ul[data-related-posts]'); - expect(relatedPosts.length).to.equal(1); + assert.equal(relatedPosts.length, 1); const relatedPost1 = relatedPosts.find('li').eq(0); - expect(relatedPost1.find('a').attr('href')).to.equal('/blog/related-1'); - expect(relatedPost1.find('a').text()).to.equal('Related post 1'); + assert.equal(relatedPost1.find('a').attr('href'), '/blog/related-1'); + assert.equal(relatedPost1.find('a').text(), 'Related post 1'); const relatedPost2 = relatedPosts.find('li').eq(1); - expect(relatedPost2.find('a').attr('href')).to.equal('/blog/related-2'); - expect(relatedPost2.find('a').text()).to.equal('Related post 2'); + assert.equal(relatedPost2.find('a').attr('href'), '/blog/related-2'); + assert.equal(relatedPost2.find('a').text(), 'Related post 2'); }); }); }); diff --git a/packages/astro/test/experimental-content-collections-css-inline-stylesheets.test.js b/packages/astro/test/experimental-content-collections-css-inline-stylesheets.nodetest.js similarity index 80% rename from packages/astro/test/experimental-content-collections-css-inline-stylesheets.test.js rename to packages/astro/test/experimental-content-collections-css-inline-stylesheets.nodetest.js index 6f762a24ff..aa4c5d133d 100644 --- a/packages/astro/test/experimental-content-collections-css-inline-stylesheets.test.js +++ b/packages/astro/test/experimental-content-collections-css-inline-stylesheets.nodetest.js @@ -1,4 +1,5 @@ -import { expect } from 'chai'; +import assert from 'node:assert/strict'; +import { describe, before, after, it } from 'node:test'; import * as cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; import testAdapter from './test-adapter.js'; @@ -30,7 +31,7 @@ describe('Experimental Content Collections cache inlineStylesheets', () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); - expect($('style').toArray()).to.be.empty; + assert.equal($('style').toArray().length, 0); }); describe('Inspect linked stylesheets', () => { @@ -77,7 +78,7 @@ describe('Experimental Content Collections cache - inlineStylesheets to never in const html = await response.text(); const $ = cheerio.load(html); - expect($('style').toArray()).to.be.empty; + assert.equal($('style').toArray().length, 0); }); describe('Inspect linked stylesheets', () => { @@ -119,15 +120,19 @@ describe.skip('Experimental Content Collections cache - inlineStylesheets to aut after(() => fixture.clean()); - it.skip('Renders some