diff --git a/packages/astro/test/asset-url-base.test.js b/packages/astro/test/asset-url-base.nodetest.js
similarity index 85%
rename from packages/astro/test/asset-url-base.test.js
rename to packages/astro/test/asset-url-base.nodetest.js
index de63ef4b7446..93695e2e7b1d 100644
--- a/packages/astro/test/asset-url-base.test.js
+++ b/packages/astro/test/asset-url-base.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';
@@ -22,7 +23,7 @@ describe('Asset URL resolution in build', () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
const href = $('link[rel=stylesheet]').attr('href');
- expect(href.startsWith('/sub/path/')).to.equal(false);
+ assert.equal(href.startsWith('/sub/path/'), false);
});
});
@@ -42,14 +43,14 @@ describe('Asset URL resolution in build', () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
const href = $('link[rel=stylesheet]').attr('href');
- expect(href.startsWith('/sub/path/')).to.equal(false);
+ assert.equal(href.startsWith('/sub/path/'), false);
});
it('does include the base subpath', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
const href = $('link[rel=stylesheet]').attr('href');
- expect(href.startsWith('/another/base/')).to.equal(true);
+ assert.equal(href.startsWith('/another/base/'), true);
});
});
});
diff --git a/packages/astro/test/astro-assets-prefix.test.js b/packages/astro/test/astro-assets-prefix.nodetest.js
similarity index 80%
rename from packages/astro/test/astro-assets-prefix.test.js
rename to packages/astro/test/astro-assets-prefix.nodetest.js
index 65613f03acee..de5aa84f4f28 100644
--- a/packages/astro/test/astro-assets-prefix.test.js
+++ b/packages/astro/test/astro-assets-prefix.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 testAdapter from './test-adapter.js';
import { loadFixture } from './test-utils.js';
@@ -22,7 +23,7 @@ describe('Assets Prefix - Static', () => {
const $ = cheerio.load(html);
const stylesheets = $('link[rel="stylesheet"]');
stylesheets.each((i, el) => {
- expect(el.attribs.href).to.match(assetsPrefixRegex);
+ assert.match(el.attribs.href, assetsPrefixRegex);
});
});
@@ -30,22 +31,22 @@ describe('Assets Prefix - Static', () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
const imgAsset = $('#image-asset');
- expect(imgAsset.attr('src')).to.match(assetsPrefixRegex);
+ assert.match(imgAsset.attr('src'), assetsPrefixRegex);
});
it('react component astro-island should import from assetsPrefix', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
const island = $('astro-island');
- expect(island.attr('component-url')).to.match(assetsPrefixRegex);
- expect(island.attr('renderer-url')).to.match(assetsPrefixRegex);
+ assert.match(island.attr('component-url'), assetsPrefixRegex);
+ assert.match(island.attr('renderer-url'), assetsPrefixRegex);
});
it('import.meta.env.ASSETS_PREFIX works', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
const env = $('#assets-prefix-env');
- expect(env.text()).to.equal(assetsPrefix);
+ assert.equal(env.text(), assetsPrefix);
});
it('markdown image src start with assetsPrefix', async () => {
@@ -53,7 +54,7 @@ describe('Assets Prefix - Static', () => {
const $ = cheerio.load(html);
const imgAssets = $('img');
imgAssets.each((i, el) => {
- expect(el.attribs.src).to.match(assetsPrefixRegex);
+ assert.match(el.attribs.src, assetsPrefixRegex);
});
});
@@ -61,7 +62,7 @@ describe('Assets Prefix - Static', () => {
const html = await fixture.readFile('/blog/index.html');
const $ = cheerio.load(html);
const imgAsset = $('img');
- expect(imgAsset.attr('src')).to.match(assetsPrefixRegex);
+ assert.match(imgAsset.attr('src'), assetsPrefixRegex);
});
});
@@ -83,7 +84,7 @@ describe('Assets Prefix - with path prefix', () => {
const $ = cheerio.load(html);
const stylesheets = $('link[rel="stylesheet"]');
stylesheets.each((i, el) => {
- expect(el.attribs.href).to.match(/^\/starting-slash\/.*/);
+ assert.match(el.attribs.href, /^\/starting-slash\/.*/);
});
});
});
@@ -104,44 +105,44 @@ describe('Assets Prefix, server', () => {
it('all stylesheets should start with assetPrefix', async () => {
const request = new Request('http://example.com/custom-base/');
const response = await app.render(request);
- expect(response.status).to.equal(200);
+ assert.equal(response.status, 200);
const html = await response.text();
const $ = cheerio.load(html);
const stylesheets = $('link[rel="stylesheet"]');
stylesheets.each((i, el) => {
- expect(el.attribs.href).to.match(assetsPrefixRegex);
+ assert.match(el.attribs.href, assetsPrefixRegex);
});
});
it('image src start with assetsPrefix', async () => {
const request = new Request('http://example.com/custom-base/');
const response = await app.render(request);
- expect(response.status).to.equal(200);
+ assert.equal(response.status, 200);
const html = await response.text();
const $ = cheerio.load(html);
const imgAsset = $('#image-asset');
- expect(imgAsset.attr('src')).to.match(assetsPrefixRegex);
+ assert.match(imgAsset.attr('src'), assetsPrefixRegex);
});
it('react component astro-island should import from assetsPrefix', async () => {
const request = new Request('http://example.com/custom-base/');
const response = await app.render(request);
- expect(response.status).to.equal(200);
+ assert.equal(response.status, 200);
const html = await response.text();
const $ = cheerio.load(html);
const island = $('astro-island');
- expect(island.attr('component-url')).to.match(assetsPrefixRegex);
- expect(island.attr('renderer-url')).to.match(assetsPrefixRegex);
+ assert.match(island.attr('component-url'), assetsPrefixRegex);
+ assert.match(island.attr('renderer-url'), assetsPrefixRegex);
});
it('markdown optimized image src does not start with assetsPrefix in SSR', async () => {
const request = new Request('http://example.com/custom-base/markdown/');
const response = await app.render(request);
- expect(response.status).to.equal(200);
+ assert.equal(response.status, 200);
const html = await response.text();
const $ = cheerio.load(html);
const imgAsset = $('img');
- expect(imgAsset.attr('src')).to.not.match(assetsPrefixRegex);
+ assert.doesNotMatch(imgAsset.attr('src'), assetsPrefixRegex);
});
});
@@ -164,12 +165,12 @@ describe('Assets Prefix, with path prefix', () => {
it('all stylesheets should start with assetPrefix', async () => {
const request = new Request('http://example.com/custom-base/');
const response = await app.render(request);
- expect(response.status).to.equal(200);
+ assert.equal(response.status, 200);
const html = await response.text();
const $ = cheerio.load(html);
const stylesheets = $('link[rel="stylesheet"]');
stylesheets.each((i, el) => {
- expect(el.attribs.href).to.match(/^\/starting-slash\/.*/);
+ assert.match(el.attribs.href, /^\/starting-slash\/.*/);
});
});
});
diff --git a/packages/astro/test/astro-assets.test.js b/packages/astro/test/astro-assets.nodetest.js
similarity index 88%
rename from packages/astro/test/astro-assets.test.js
rename to packages/astro/test/astro-assets.nodetest.js
index 7daa4aaa3daa..266159b707b8 100644
--- a/packages/astro/test/astro-assets.test.js
+++ b/packages/astro/test/astro-assets.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';
import srcsetParse from 'srcset-parse';
@@ -22,7 +23,7 @@ describe('Assets', () => {
const $ = cheerio.load(html);
const imgPath = $('img').attr('src');
const data = await fixture.readFile(imgPath);
- expect(!!data).to.equal(true);
+ assert.equal(!!data, true);
});
it('built the 2x image', async () => {
@@ -32,7 +33,7 @@ describe('Assets', () => {
const candidates = matchSrcset(srcset);
const match = candidates.find((a) => a.density === 2);
const data = await fixture.readFile(match.url);
- expect(!!data).to.equal(true);
+ assert.equal(!!data, true);
});
it('built the 3x image', async () => {
@@ -42,7 +43,7 @@ describe('Assets', () => {
const candidates = matchSrcset(srcset);
const match = candidates.find((a) => a.density === 3);
const data = await fixture.readFile(match.url);
- expect(!!data).to.equal(true);
+ assert.equal(!!data, true);
});
it('built image from an import specifier', async () => {
@@ -50,7 +51,7 @@ describe('Assets', () => {
const $ = cheerio.load(html);
const src = $('#import-no-url').attr('src');
const data = await fixture.readFile(src);
- expect(!!data).to.equal(true);
+ assert.equal(!!data, true);
});
it('built image from an import specifier using ?url', async () => {
@@ -58,6 +59,6 @@ describe('Assets', () => {
const $ = cheerio.load(html);
const src = $('#import-url').attr('src');
const data = await fixture.readFile(src);
- expect(!!data).to.equal(true);
+ assert.equal(!!data, true);
});
});
diff --git a/packages/astro/test/astro-attrs.test.js b/packages/astro/test/astro-attrs.nodetest.js
similarity index 76%
rename from packages/astro/test/astro-attrs.test.js
rename to packages/astro/test/astro-attrs.nodetest.js
index d2d5859506ca..a3a8b7e81737 100644
--- a/packages/astro/test/astro-attrs.test.js
+++ b/packages/astro/test/astro-attrs.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';
@@ -33,7 +34,7 @@ describe('Attributes', async () => {
for (const id of Object.keys(attrs)) {
const { attribute, value } = attrs[id];
const attr = $(`#${id}`).attr(attribute);
- expect(attr).to.equal(value);
+ assert.equal(attr, value);
}
});
@@ -41,24 +42,24 @@ describe('Attributes', async () => {
const html = await fixture.readFile('/component/index.html');
const $ = cheerio.load(html);
- expect($('#true').attr('attr')).to.equal('attr-true');
- expect($('#true').attr('type')).to.equal('boolean');
- expect($('#false').attr('attr')).to.equal('attr-false');
- expect($('#false').attr('type')).to.equal('boolean');
+ assert.equal($('#true').attr('attr'), 'attr-true');
+ assert.equal($('#true').attr('type'), 'boolean');
+ assert.equal($('#false').attr('attr'), 'attr-false');
+ assert.equal($('#false').attr('type'), 'boolean');
});
it('Passes namespaced attributes as expected', async () => {
const html = await fixture.readFile('/namespaced/index.html');
const $ = cheerio.load(html);
- expect($('div').attr('xmlns:happy')).to.equal('https://example.com/schemas/happy');
- expect($('img').attr('happy:smile')).to.equal('sweet');
+ assert.equal($('div').attr('xmlns:happy'), 'https://example.com/schemas/happy');
+ assert.equal($('img').attr('happy:smile'), 'sweet');
});
it('Passes namespaced attributes to components as expected', async () => {
const html = await fixture.readFile('/namespaced-component/index.html');
const $ = cheerio.load(html);
- expect($('span').attr('on:click')).to.deep.equal('(event) => console.log(event)');
+ assert.deepEqual($('span').attr('on:click'), '(event) => console.log(event)');
});
});
diff --git a/packages/astro/test/astro-basic.test.js b/packages/astro/test/astro-basic.nodetest.js
similarity index 63%
rename from packages/astro/test/astro-basic.test.js
rename to packages/astro/test/astro-basic.nodetest.js
index 6bd78c2d3360..f363d7287549 100644
--- a/packages/astro/test/astro-basic.test.js
+++ b/packages/astro/test/astro-basic.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 * as cheerio from 'cheerio';
import { loadFixture } from './test-utils.js';
@@ -25,70 +26,70 @@ describe('Astro basic build', () => {
const html = await fixture.readFile(`/index.html`);
const $ = cheerio.load(html);
- expect($('h1').text()).to.equal('Hello world!');
+ assert.equal($('h1').text(), 'Hello world!');
});
it('Correctly serializes boolean attributes', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
- expect($('h1').attr('data-something')).to.equal('');
- expect($('h2').attr('not-data-ok')).to.equal('');
+ assert.equal($('h1').attr('data-something'), '');
+ assert.equal($('h2').attr('not-data-ok'), '');
});
it('Selector with an empty body', async () => {
const html = await fixture.readFile('/empty-class/index.html');
const $ = cheerio.load(html);
- expect($('.author')).to.have.lengthOf(1);
+ assert.equal($('.author').length, 1);
});
it('Allows forward-slashes in mustache tags (#407)', async () => {
const html = await fixture.readFile('/forward-slash/index.html');
const $ = cheerio.load(html);
- expect($('a[href="/post/one"]')).to.have.lengthOf(1);
- expect($('a[href="/post/two"]')).to.have.lengthOf(1);
- expect($('a[href="/post/three"]')).to.have.lengthOf(1);
+ assert.equal($('a[href="/post/one"]').length, 1);
+ assert.equal($('a[href="/post/two"]').length, 1);
+ assert.equal($('a[href="/post/three"]').length, 1);
});
it('Allows spread attributes (#521)', async () => {
const html = await fixture.readFile('/spread/index.html');
const $ = cheerio.load(html);
- expect($('#spread-leading')).to.have.lengthOf(1);
- expect($('#spread-leading').attr('a')).to.equal('0');
- expect($('#spread-leading').attr('b')).to.equal('1');
- expect($('#spread-leading').attr('c')).to.equal('2');
+ assert.equal($('#spread-leading').length, 1);
+ assert.equal($('#spread-leading').attr('a'), '0');
+ assert.equal($('#spread-leading').attr('b'), '1');
+ assert.equal($('#spread-leading').attr('c'), '2');
- expect($('#spread-trailing')).to.have.lengthOf(1);
- expect($('#spread-trailing').attr('a')).to.equal('0');
- expect($('#spread-trailing').attr('b')).to.equal('1');
- expect($('#spread-trailing').attr('c')).to.equal('2');
+ assert.equal($('#spread-trailing').length, 1);
+ assert.equal($('#spread-trailing').attr('a'), '0');
+ assert.equal($('#spread-trailing').attr('b'), '1');
+ assert.equal($('#spread-trailing').attr('c'), '2');
});
it('Allows spread attributes with TypeScript (#521)', async () => {
const html = await fixture.readFile('/spread/index.html');
const $ = cheerio.load(html);
- expect($('#spread-ts')).to.have.lengthOf(1);
- expect($('#spread-ts').attr('a')).to.equal('0');
- expect($('#spread-ts').attr('b')).to.equal('1');
- expect($('#spread-ts').attr('c')).to.equal('2');
+ assert.equal($('#spread-ts').length, 1);
+ assert.equal($('#spread-ts').attr('a'), '0');
+ assert.equal($('#spread-ts').attr('b'), '1');
+ assert.equal($('#spread-ts').attr('c'), '2');
});
it('Allows scoped classes with spread', async () => {
const html = await fixture.readFile('/spread-scope/index.html');
const $ = cheerio.load(html);
- expect($('#spread-plain')).to.have.lengthOf(1);
- expect($('#spread-plain').attr('class')).to.match(/astro-.*/);
+ assert.equal($('#spread-plain').length, 1);
+ assert.match($('#spread-plain').attr('class'), /astro-.*/);
- expect($('#spread-class')).to.have.lengthOf(1);
- expect($('#spread-class').attr('class')).to.match(/astro-.*/);
+ assert.equal($('#spread-class').length, 1);
+ assert.match($('#spread-class').attr('class'), /astro-.*/);
- expect($('#spread-class-list')).to.have.lengthOf(1);
- expect($('#spread-class-list').attr('class')).to.match(/astro-.*/);
+ assert.equal($('#spread-class-list').length, 1);
+ assert.match($('#spread-class-list').attr('class'), /astro-.*/);
});
it('Allows using the Fragment element to be used', async () => {
@@ -96,30 +97,30 @@ describe('Astro basic build', () => {
const $ = cheerio.load(html);
// will be 1 if element rendered correctly
- expect($('#one')).to.have.lengthOf(1);
+ assert.strictEqual($('#one').length, 1);
});
it('supports special chars in filename', async () => {
// will have already erred by now, but add test anyway
- expect(await fixture.readFile('/special-“characters” -in-file/index.html')).to.be.ok;
+ assert.ok(await fixture.readFile('/special-“characters” -in-file/index.html'));
});
it('renders the components top-down', async () => {
const html = await fixture.readFile('/order/index.html');
const $ = cheerio.load(html);
- expect($('#rendered-order').text()).to.eq('Rendered order: A, B');
+ assert.strictEqual($('#rendered-order').text(), 'Rendered order: A, B');
});
it('renders markdown in utf-8 by default', async () => {
const html = await fixture.readFile('/chinese-encoding-md/index.html');
const $ = cheerio.load(html);
- expect($('h1').text()).to.equal('我的第一篇博客文章');
+ assert.strictEqual($('h1').text(), '我的第一篇博客文章');
});
it('renders MDX in utf-8 by default', async () => {
const html = await fixture.readFile('/chinese-encoding-mdx/index.html');
const $ = cheerio.load(html);
- expect($('h1').text()).to.equal('我的第一篇博客文章');
+ assert.strictEqual($('h1').text(), '我的第一篇博客文章');
});
it('Supports void elements whose name is a string (#2062)', async () => {
@@ -127,45 +128,49 @@ describe('Astro basic build', () => {
const $ = cheerio.load(html);
//
- expect($('body > :nth-child(1)').prop('outerHTML')).to.equal('');
+ assert.strictEqual($('body > :nth-child(1)').prop('outerHTML'), '');
//
- expect($('body > :nth-child(2)').prop('outerHTML')).to.equal('');
+ assert.strictEqual($('body > :nth-child(2)').prop('outerHTML'), '');
//
- expect($('body > :nth-child(3)').prop('outerHTML')).to.equal('');
+ assert.strictEqual($('body > :nth-child(3)').prop('outerHTML'), '');
//
- expect($('body > :nth-child(4)').prop('outerHTML')).to.equal(
+ assert.strictEqual(
+ $('body > :nth-child(4)').prop('outerHTML'),
''
);
// textarea
- expect($('body > :nth-child(5)').prop('outerHTML')).to.equal('');
+ assert.strictEqual(
+ $('body > :nth-child(5)').prop('outerHTML'),
+ ''
+ );
});
it('Generates pages that end with .mjs', async () => {
const content1 = await fixture.readFile('/get-static-paths-with-mjs/example.mjs');
- expect(content1).to.be.ok;
+ assert.ok(content1);
const content2 = await fixture.readFile('/get-static-paths-with-mjs/example.js');
- expect(content2).to.be.ok;
+ assert.ok(content2);
});
it('allows file:// urls as module specifiers', async () => {
const html = await fixture.readFile('/fileurl/index.html');
const $ = cheerio.load(html);
- expect($('h1').text()).to.equal('WORKS');
+ assert.strictEqual($('h1').text(), 'WORKS');
});
describe('preview', () => {
it('returns 200 for valid URLs', async () => {
const result = await fixture.fetch('/');
- expect(result.status).to.equal(200);
+ assert.strictEqual(result.status, 200);
});
it('returns 404 for invalid URLs', async () => {
const result = await fixture.fetch('/bad-url');
- expect(result.status).to.equal(404);
+ assert.strictEqual(result.status, 404);
});
});
});
@@ -188,25 +193,25 @@ describe('Astro basic development', () => {
it('Renders markdown in utf-8 by default', async () => {
const res = await fixture.fetch('/chinese-encoding-md');
- expect(res.status).to.equal(200);
+ assert.strictEqual(res.status, 200);
const html = await res.text();
const $ = cheerio.load(html);
- expect($('h1').text()).to.equal('我的第一篇博客文章');
+ assert.equal($('h1').text(), '我的第一篇博客文章');
const isUtf8 =
res.headers.get('content-type').includes('charset=utf-8') ||
html.includes('');
- expect(isUtf8).to.be.true;
+ assert.ok(isUtf8);
});
it('Renders MDX in utf-8 by default', async () => {
const res = await fixture.fetch('/chinese-encoding-mdx');
- expect(res.status).to.equal(200);
+ assert.strictEqual(res.status, 200);
const html = await res.text();
const $ = cheerio.load(html);
- expect($('h1').text()).to.equal('我的第一篇博客文章');
+ assert.equal($('h1').text(), '我的第一篇博客文章');
const isUtf8 =
res.headers.get('content-type').includes('charset=utf-8') ||
html.includes('');
- expect(isUtf8).to.be.true;
+ assert.ok(isUtf8);
});
});
diff --git a/packages/astro/test/astro-children.test.js b/packages/astro/test/astro-children.nodetest.js
similarity index 55%
rename from packages/astro/test/astro-children.test.js
rename to packages/astro/test/astro-children.nodetest.js
index 8a396cce4901..884442804eea 100644
--- a/packages/astro/test/astro-children.test.js
+++ b/packages/astro/test/astro-children.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';
@@ -16,15 +17,15 @@ describe('Component children', () => {
// test 1: Can pass text to Preact components
const $preact = $('#preact');
- expect($preact.text().trim()).to.equal('Hello world');
+ assert.strictEqual($preact.text().trim(), 'Hello world');
// test 2: Can pass text to Vue components
const $vue = $('#vue');
- expect($vue.text().trim()).to.equal('Hello world');
+ assert.strictEqual($vue.text().trim(), 'Hello world');
// test 3: Can pass text to Svelte components
const $svelte = $('#svelte');
- expect($svelte.text().trim()).to.equal('Hello world');
+ assert.strictEqual($svelte.text().trim(), 'Hello world');
});
it('Passes markup children to framework components', async () => {
@@ -33,15 +34,15 @@ describe('Component children', () => {
// test 1: Can pass markup to Preact components
const $preact = $('#preact h1');
- expect($preact.text().trim()).to.equal('Hello world');
+ assert.strictEqual($preact.text().trim(), 'Hello world');
// test 2: Can pass markup to Vue components
const $vue = $('#vue h1');
- expect($vue.text().trim()).to.equal('Hello world');
+ assert.strictEqual($vue.text().trim(), 'Hello world');
// test 3: Can pass markup to Svelte components
const $svelte = $('#svelte h1');
- expect($svelte.text().trim()).to.equal('Hello world');
+ assert.strictEqual($svelte.text().trim(), 'Hello world');
});
it('Passes multiple children to framework components', async () => {
@@ -50,21 +51,21 @@ describe('Component children', () => {
// test 1: Can pass multiple children to Preact components
const $preact = $('#preact');
- expect($preact.children()).to.have.lengthOf(2);
- expect($preact.children(':first-child').text().trim()).to.equal('Hello world');
- expect($preact.children(':last-child').text().trim()).to.equal('Goodbye world');
+ assert.strictEqual($preact.children().length, 2);
+ assert.strictEqual($preact.children(':first-child').text().trim(), 'Hello world');
+ assert.strictEqual($preact.children(':last-child').text().trim(), 'Goodbye world');
// test 2: Can pass multiple children to Vue components
const $vue = $('#vue');
- expect($vue.children()).to.have.lengthOf(2);
- expect($vue.children(':first-child').text().trim()).to.equal('Hello world');
- expect($vue.children(':last-child').text().trim()).to.equal('Goodbye world');
+ assert.strictEqual($vue.children().length, 2);
+ assert.strictEqual($vue.children(':first-child').text().trim(), 'Hello world');
+ assert.strictEqual($vue.children(':last-child').text().trim(), 'Goodbye world');
// test 3: Can pass multiple children to Svelte components
const $svelte = $('#svelte');
- expect($svelte.children()).to.have.lengthOf(2);
- expect($svelte.children(':first-child').text().trim()).to.equal('Hello world');
- expect($svelte.children(':last-child').text().trim()).to.equal('Goodbye world');
+ assert.strictEqual($svelte.children().length, 2);
+ assert.strictEqual($svelte.children(':first-child').text().trim(), 'Hello world');
+ assert.strictEqual($svelte.children(':last-child').text().trim(), 'Goodbye world');
});
it('Renders a template when children are not rendered for client components', async () => {
@@ -72,24 +73,26 @@ describe('Component children', () => {
const $ = cheerio.load(html);
// test 1: If SSR only, no children are rendered.
- expect($('#ssr-only').children()).to.have.lengthOf(0);
+ assert.strictEqual($('#ssr-only').children().length, 0);
// test 2: If client, and no children are rendered, a template is.
- expect($('#client').parent().children()).to.have.lengthOf(
+ assert.strictEqual(
+ $('#client').parent().children().length,
2,
'rendered the client component and a template'
);
- expect($('#client').parent().find('template[data-astro-template]')).to.have.lengthOf(
+ assert.strictEqual(
+ $('#client').parent().find('template[data-astro-template]').length,
1,
'Found 1 template'
);
// test 3: If client, and children are rendered, no template is.
- expect($('#client-render').parent().children()).to.have.lengthOf(1);
- expect($('#client-render').parent().find('template')).to.have.lengthOf(0);
+ assert.strictEqual($('#client-render').parent().children().length, 1);
+ assert.strictEqual($('#client-render').parent().find('template').length, 0);
// test 4: If client and no children are provided, no template is.
- expect($('#client-no-children').parent().children()).to.have.lengthOf(1);
- expect($('#client-no-children').parent().find('template')).to.have.lengthOf(0);
+ assert.strictEqual($('#client-no-children').parent().children().length, 1);
+ assert.strictEqual($('#client-no-children').parent().find('template').length, 0);
});
});
diff --git a/packages/astro/test/astro-class-list.nodetest.js b/packages/astro/test/astro-class-list.nodetest.js
new file mode 100644
index 000000000000..7d300e997fe9
--- /dev/null
+++ b/packages/astro/test/astro-class-list.nodetest.js
@@ -0,0 +1,63 @@
+import assert from 'node:assert/strict';
+import { describe, before, it } from 'node:test';
+import * as cheerio from 'cheerio';
+import { loadFixture } from './test-utils.js';
+
+describe('Class List', async () => {
+ let fixture;
+
+ before(async () => {
+ fixture = await loadFixture({ root: './fixtures/astro-class-list/' });
+ await fixture.build();
+ });
+
+ it('Passes class:list attributes as expected to elements', async () => {
+ const html = await fixture.readFile('/index.html');
+ const $ = cheerio.load(html);
+
+ assert.equal($('[class="test control"]').length, 1, '[class="test control"]');
+ assert.equal($('[class="test expression"]').length, 1, '[class="test expression"]');
+ assert.equal($('[class="test true"]').length, 1, '[class="test true"]');
+ assert.equal($('[class="test truthy"]').length, 1, '[class="test truthy"]');
+ assert.equal($('[class="test set"]').length, 1, '[class="test set"]');
+ assert.equal(
+ $('[class="hello goodbye hello world hello friend"]').length,
+ 1,
+ '[class="hello goodbye hello world hello friend"]'
+ );
+ assert.equal($('[class="foo baz"]').length, 1, '[class="foo baz"]');
+ assert.equal($('span:not([class])').length, 1, 'span:not([class])');
+
+ assert.equal($('.false, .noshow1, .noshow2, .noshow3, .noshow4').length, 0);
+ });
+
+ it('Passes class:list attributes as expected to components', async () => {
+ const html = await fixture.readFile('/component/index.html');
+ const $ = cheerio.load(html);
+
+ assert.equal($('[class="test control"]').length, 1, '[class="test control"]');
+ assert.equal($('[class="test expression"]').length, 1, '[class="test expression"]');
+ assert.equal($('[class="test true"]').length, 1, '[class="test true"]');
+ assert.equal($('[class="test truthy"]').length, 1, '[class="test truthy"]');
+ assert.equal($('[class="test set"]').length, 1, '[class="test set"]');
+ assert.equal(
+ $('[class="hello goodbye hello world hello friend"]').length,
+ 1,
+ '[class="hello goodbye hello world hello friend"]'
+ );
+ assert.equal($('[class="foo baz"]').length, 1, '[class="foo baz"]');
+ assert.equal($('span:not([class])').length, 1, 'span:not([class])');
+
+ assert.equal($('[class="test control"]').text(), 'test control');
+ assert.equal($('[class="test expression"]').text(), 'test expression');
+ assert.equal($('[class="test true"]').text(), 'test true');
+ assert.equal($('[class="test truthy"]').text(), 'test truthy');
+ assert.equal($('[class="test set"]').text(), 'test set');
+ assert.equal(
+ $('[class="hello goodbye hello world hello friend"]').text(),
+ 'hello goodbye hello world hello friend'
+ );
+ assert.equal($('[class="foo baz"]').text(), 'foo baz');
+ assert.equal($('span:not([class])').text(), '');
+ });
+});
diff --git a/packages/astro/test/astro-class-list.test.js b/packages/astro/test/astro-class-list.test.js
deleted file mode 100644
index 4fd7cd13f718..000000000000
--- a/packages/astro/test/astro-class-list.test.js
+++ /dev/null
@@ -1,59 +0,0 @@
-import { expect } from 'chai';
-import * as cheerio from 'cheerio';
-import { loadFixture } from './test-utils.js';
-
-describe('Class List', async () => {
- let fixture;
-
- before(async () => {
- fixture = await loadFixture({ root: './fixtures/astro-class-list/' });
- await fixture.build();
- });
-
- it('Passes class:list attributes as expected to elements', async () => {
- const html = await fixture.readFile('/index.html');
- const $ = cheerio.load(html);
-
- expect($('[class="test control"]')).to.have.lengthOf(1, '[class="test control"]');
- expect($('[class="test expression"]')).to.have.lengthOf(1, '[class="test expression"]');
- expect($('[class="test true"]')).to.have.lengthOf(1, '[class="test true"]');
- expect($('[class="test truthy"]')).to.have.lengthOf(1, '[class="test truthy"]');
- expect($('[class="test set"]')).to.have.lengthOf(1, '[class="test set"]');
- expect($('[class="hello goodbye hello world hello friend"]')).to.have.lengthOf(
- 1,
- '[class="hello goodbye hello world hello friend"]'
- );
- expect($('[class="foo baz"]')).to.have.lengthOf(1, '[class="foo baz"]');
- expect($('span:not([class])')).to.have.lengthOf(1, 'span:not([class])');
-
- expect($('.false, .noshow1, .noshow2, .noshow3, .noshow4')).to.have.lengthOf(0);
- });
-
- it('Passes class:list attributes as expected to components', async () => {
- const html = await fixture.readFile('/component/index.html');
- const $ = cheerio.load(html);
-
- expect($('[class="test control"]')).to.have.lengthOf(1, '[class="test control"]');
- expect($('[class="test expression"]')).to.have.lengthOf(1, '[class="test expression"]');
- expect($('[class="test true"]')).to.have.lengthOf(1, '[class="test true"]');
- expect($('[class="test truthy"]')).to.have.lengthOf(1, '[class="test truthy"]');
- expect($('[class="test set"]')).to.have.lengthOf(1, '[class="test set"]');
- expect($('[class="hello goodbye hello world hello friend"]')).to.have.lengthOf(
- 1,
- '[class="hello goodbye hello world hello friend"]'
- );
- expect($('[class="foo baz"]')).to.have.lengthOf(1, '[class="foo baz"]');
- expect($('span:not([class])')).to.have.lengthOf(1, 'span:not([class])');
-
- expect($('[class="test control"]').text()).to.equal('test control');
- expect($('[class="test expression"]').text()).to.equal('test expression');
- expect($('[class="test true"]').text()).to.equal('test true');
- expect($('[class="test truthy"]').text()).to.equal('test truthy');
- expect($('[class="test set"]').text()).to.equal('test set');
- expect($('[class="hello goodbye hello world hello friend"]').text()).to.equal(
- 'hello goodbye hello world hello friend'
- );
- expect($('[class="foo baz"]').text()).to.equal('foo baz');
- expect($('span:not([class])').text()).to.equal('');
- });
-});
diff --git a/packages/astro/test/astro-component-bundling.test.js b/packages/astro/test/astro-component-bundling.nodetest.js
similarity index 77%
rename from packages/astro/test/astro-component-bundling.test.js
rename to packages/astro/test/astro-component-bundling.nodetest.js
index 9a12919429a9..2d8b75aa55a6 100644
--- a/packages/astro/test/astro-component-bundling.test.js
+++ b/packages/astro/test/astro-component-bundling.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';
describe('Component bundling', () => {
@@ -15,6 +16,6 @@ describe('Component bundling', () => {
chunk.startsWith('ManyComponents')
);
const manyComponentsChunkContent = await fixture.readFile(`/_astro/${manyComponentsChunkName}`);
- expect(manyComponentsChunkContent).to.not.include('FooComponent');
+ assert.equal(manyComponentsChunkContent.includes('FooComponent'), false);
});
});
diff --git a/packages/astro/test/astro-external-files.test.js b/packages/astro/test/astro-external-files.nodetest.js
similarity index 70%
rename from packages/astro/test/astro-external-files.test.js
rename to packages/astro/test/astro-external-files.nodetest.js
index 7aaf04c80339..5db44bc21a55 100644
--- a/packages/astro/test/astro-external-files.test.js
+++ b/packages/astro/test/astro-external-files.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';
describe('External file references', () => {
@@ -11,7 +12,7 @@ describe('External file references', () => {
it('Build with externeal reference', async () => {
const html = await fixture.readFile('/index.html');
- expect(html).to.include('