From 40a2e03ffb86d4b64838ed90a5d464d32db1b589 Mon Sep 17 00:00:00 2001 From: Marawan Mohamed <40841193+marwan-mohamed12@users.noreply.github.com> Date: Thu, 15 Feb 2024 12:27:05 +0200 Subject: [PATCH] chore: move tests to node (#10115) --- ...rt.test.js => featuresSupport.nodetest.js} | 17 ++++++++++---- .../test/{fetch.test.js => fetch.nodetest.js} | 23 ++++++++----------- ...tsource.test.js => fontsource.nodetest.js} | 5 ++-- 3 files changed, 24 insertions(+), 21 deletions(-) rename packages/astro/test/{featuresSupport.test.js => featuresSupport.nodetest.js} (69%) rename packages/astro/test/{fetch.test.js => fetch.nodetest.js} (54%) rename packages/astro/test/{fontsource.test.js => fontsource.nodetest.js} (78%) diff --git a/packages/astro/test/featuresSupport.test.js b/packages/astro/test/featuresSupport.nodetest.js similarity index 69% rename from packages/astro/test/featuresSupport.test.js rename to packages/astro/test/featuresSupport.nodetest.js index 15606b927c..b87b0fc94d 100644 --- a/packages/astro/test/featuresSupport.test.js +++ b/packages/astro/test/featuresSupport.nodetest.js @@ -1,5 +1,6 @@ import { loadFixture } from './test-utils.js'; -import { expect } from 'chai'; +import assert from 'node:assert/strict'; +import { describe, it } from 'node:test'; import testAdapter from './test-adapter.js'; describe('Adapter', () => { @@ -18,8 +19,11 @@ describe('Adapter', () => { }); await fixture.build(); } catch (e) { - expect(e.toString()).to.contain( - "The adapter my-ssr-adapter doesn't support the feature build.excludeMiddleware." + assert.equal( + e + .toString() + .includes("The adapter my-ssr-adapter doesn't support the feature build.middleware."), + true ); } }); @@ -37,8 +41,11 @@ describe('Adapter', () => { }); await fixture.build(); } catch (e) { - expect(e.toString()).to.contain( - "The adapter my-ssr-adapter doesn't support the feature build.split." + assert.equal( + e + .toString() + .includes("The adapter my-ssr-adapter doesn't support the feature build.split."), + true ); } }); diff --git a/packages/astro/test/fetch.test.js b/packages/astro/test/fetch.nodetest.js similarity index 54% rename from packages/astro/test/fetch.test.js rename to packages/astro/test/fetch.nodetest.js index 053c7683eb..846e0c8a38 100644 --- a/packages/astro/test/fetch.test.js +++ b/packages/astro/test/fetch.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'; @@ -13,30 +14,24 @@ describe('Global Fetch', () => { it('Is available in Astro pages', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); - expect($('#astro-page').text()).to.equal('function', 'Fetch supported in .astro page'); + assert.equal($('#astro-page').text(), 'function', 'Fetch supported in .astro page'); }); it('Is available in Astro components', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); - expect($('#astro-component').text()).to.equal( - 'function', - 'Fetch supported in .astro components' - ); + assert.equal($('#astro-component').text(), 'function', 'Fetch supported in .astro components'); }); it('Is available in non-Astro components', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); - expect($('#jsx').text()).to.equal('function', 'Fetch supported in .jsx'); - expect($('#svelte').text()).to.equal('function', 'Fetch supported in .svelte'); - expect($('#vue').text()).to.equal('function', 'Fetch supported in .vue'); + assert.equal($('#jsx').text(), 'function', 'Fetch supported in .jsx'); + assert.equal($('#svelte').text(), 'function', 'Fetch supported in .svelte'); + assert.equal($('#vue').text(), 'function', 'Fetch supported in .vue'); }); it('Respects existing code', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); - expect($('#already-imported').text()).to.equal('function', 'Existing fetch imports respected'); - expect($('#custom-declaration').text()).to.equal( - 'number', - 'Custom fetch declarations respected' - ); + assert.equal($('#already-imported').text(), 'function', 'Existing fetch imports respected'); + assert.equal($('#custom-declaration').text(), 'number', 'Custom fetch declarations respected'); }); }); diff --git a/packages/astro/test/fontsource.test.js b/packages/astro/test/fontsource.nodetest.js similarity index 78% rename from packages/astro/test/fontsource.test.js rename to packages/astro/test/fontsource.nodetest.js index 1c75d01254..41b50bd5e7 100644 --- a/packages/astro/test/fontsource.test.js +++ b/packages/astro/test/fontsource.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,6 +16,6 @@ describe('@fontsource/* packages', () => { const $ = cheerio.load(html); const assetPath = $('link').attr('href'); const css = await fixture.readFile(assetPath); - expect(css).to.contain('Montserrat'); + assert.equal(css.includes('Montserrat'), true); }); });