diff --git a/packages/integrations/sitemap/package.json b/packages/integrations/sitemap/package.json index 2bc76067d3..c50359c73a 100644 --- a/packages/integrations/sitemap/package.json +++ b/packages/integrations/sitemap/package.json @@ -30,7 +30,7 @@ "build": "astro-scripts build \"src/**/*.ts\" && tsc", "build:ci": "astro-scripts build \"src/**/*.ts\"", "dev": "astro-scripts dev \"src/**/*.ts\"", - "test": "astro-scripts test \"test/**/*.test.js\"" + "test": "mocha --timeout 20000" }, "dependencies": { "sitemap": "^7.1.1", @@ -40,6 +40,8 @@ "@astrojs/node": "workspace:*", "astro": "workspace:*", "astro-scripts": "workspace:*", + "chai": "^4.3.7", + "mocha": "^10.2.0", "xml2js": "0.6.2" }, "publishConfig": { diff --git a/packages/integrations/sitemap/test/base-path.test.js b/packages/integrations/sitemap/test/base-path.test.js index 96bf5e209b..a90f28c302 100644 --- a/packages/integrations/sitemap/test/base-path.test.js +++ b/packages/integrations/sitemap/test/base-path.test.js @@ -1,6 +1,5 @@ import { loadFixture, readXML } from './test-utils.js'; -import * as assert from 'node:assert/strict'; -import { describe, it, before } from 'node:test'; +import { expect } from 'chai'; describe('URLs with base path', () => { /** @type {import('./test-utils').Fixture} */ @@ -18,7 +17,7 @@ describe('URLs with base path', () => { it('Base path is concatenated correctly', async () => { const data = await readXML(fixture.readFile('/client/sitemap-0.xml')); const urls = data.urlset.url; - assert.equal(urls[0].loc[0], 'http://example.com/base/one/'); + expect(urls[0].loc[0]).to.equal('http://example.com/base/one/'); }); }); @@ -34,7 +33,7 @@ describe('URLs with base path', () => { it('Base path is concatenated correctly', async () => { const data = await readXML(fixture.readFile('/sitemap-0.xml')); const urls = data.urlset.url; - assert.equal(urls[0].loc[0], 'http://example.com/base/123/'); + expect(urls[0].loc[0]).to.equal('http://example.com/base/123/'); }); }); }); diff --git a/packages/integrations/sitemap/test/filter.test.js b/packages/integrations/sitemap/test/filter.test.js index c8c00e1e75..b262324817 100644 --- a/packages/integrations/sitemap/test/filter.test.js +++ b/packages/integrations/sitemap/test/filter.test.js @@ -1,7 +1,6 @@ import { loadFixture, readXML } from './test-utils.js'; +import { expect } from 'chai'; import { sitemap } from './fixtures/static/deps.mjs'; -import * as assert from 'node:assert/strict'; -import { describe, it, before } from 'node:test'; describe('Filter support', () => { /** @type {import('./test-utils.js').Fixture} */ @@ -23,7 +22,7 @@ describe('Filter support', () => { it('Just one page is added', async () => { const data = await readXML(fixture.readFile('/sitemap-0.xml')); const urls = data.urlset.url; - assert.equal(urls.length, 1); + expect(urls.length).to.equal(1); }); }); @@ -43,7 +42,7 @@ describe('Filter support', () => { it('Just one page is added', async () => { const data = await readXML(fixture.readFile('/client/sitemap-0.xml')); const urls = data.urlset.url; - assert.equal(urls.length, 1); + expect(urls.length).to.equal(1); }); }); }); diff --git a/packages/integrations/sitemap/test/routes.test.js b/packages/integrations/sitemap/test/routes.test.js index b7f39e4048..909580dd9c 100644 --- a/packages/integrations/sitemap/test/routes.test.js +++ b/packages/integrations/sitemap/test/routes.test.js @@ -1,6 +1,5 @@ import { loadFixture, readXML } from './test-utils.js'; -import * as assert from 'node:assert/strict'; -import { describe, it, before } from 'node:test'; +import { expect } from 'chai'; describe('routes', () => { /** @type {import('./test-utils.js').Fixture} */ @@ -18,10 +17,10 @@ describe('routes', () => { }); it('does not include endpoints', async () => { - assert.equal(urls.indexOf('http://example.com/endpoint.json'), -1); + expect(urls).to.not.include('http://example.com/endpoint.json'); }); it('does not include redirects', async () => { - assert.equal(urls.indexOf('http://example.com/endpoint.json'), -1); + expect(urls).to.not.include('http://example.com/redirect'); }); }); diff --git a/packages/integrations/sitemap/test/ssr.test.js b/packages/integrations/sitemap/test/ssr.test.js index 7622f266b8..e6f8412d56 100644 --- a/packages/integrations/sitemap/test/ssr.test.js +++ b/packages/integrations/sitemap/test/ssr.test.js @@ -1,6 +1,5 @@ import { loadFixture, readXML } from './test-utils.js'; -import * as assert from 'node:assert/strict'; -import { describe, it, before } from 'node:test'; +import { expect } from 'chai'; describe('SSR support', () => { /** @type {import('./test-utils.js').Fixture} */ @@ -17,7 +16,7 @@ describe('SSR support', () => { const data = await readXML(fixture.readFile('/client/sitemap-0.xml')); const urls = data.urlset.url; - assert.equal(urls[0].loc[0], 'http://example.com/one/'); - assert.equal(urls[1].loc[0], 'http://example.com/two/'); + expect(urls[0].loc[0]).to.equal('http://example.com/one/'); + expect(urls[1].loc[0]).to.equal('http://example.com/two/'); }); }); diff --git a/packages/integrations/sitemap/test/staticPaths.test.js b/packages/integrations/sitemap/test/staticPaths.test.js index b4463c0d2e..603af163d1 100644 --- a/packages/integrations/sitemap/test/staticPaths.test.js +++ b/packages/integrations/sitemap/test/staticPaths.test.js @@ -1,6 +1,5 @@ import { loadFixture, readXML } from './test-utils.js'; -import * as assert from 'node:assert/strict'; -import { describe, it, before } from 'node:test'; +import { expect } from 'chai'; describe('getStaticPaths support', () => { /** @type {import('./test-utils.js').Fixture} */ @@ -20,24 +19,24 @@ describe('getStaticPaths support', () => { }); it('requires zero config for getStaticPaths', async () => { - assert.strictEqual(urls.includes('http://example.com/one/'), true); - assert.strictEqual(urls.includes('http://example.com/two/'), true); + expect(urls).to.include('http://example.com/one/'); + expect(urls).to.include('http://example.com/two/'); }); it('does not include 404 pages', () => { - assert.strictEqual(urls.includes('http://example.com/de/404/'), false); + expect(urls).to.not.include('http://example.com/404/'); }); it('does not include nested 404 pages', () => { - assert.strictEqual(urls.includes('http://example.com/de/404/'), false); + expect(urls).to.not.include('http://example.com/de/404/'); }); it('includes numerical pages', () => { - assert.strictEqual(urls.includes('http://example.com/123/'), true); + expect(urls).to.include('http://example.com/123/'); }); it('should render the endpoint', async () => { const page = await fixture.readFile('./it/manifest'); - assert.strictEqual(page.includes('I\'m a route in the "it" language.'), true); + expect(page).to.contain('I\'m a route in the "it" language.'); }); }); diff --git a/packages/integrations/sitemap/test/trailing-slash.test.js b/packages/integrations/sitemap/test/trailing-slash.test.js index d51ed20203..a393fb9f12 100644 --- a/packages/integrations/sitemap/test/trailing-slash.test.js +++ b/packages/integrations/sitemap/test/trailing-slash.test.js @@ -1,6 +1,5 @@ import { loadFixture, readXML } from './test-utils.js'; -import * as assert from 'node:assert/strict'; -import { describe, it, before } from 'node:test'; +import { expect } from 'chai'; describe('Trailing slash', () => { /** @type {import('./test-utils').Fixture} */ @@ -22,7 +21,7 @@ describe('Trailing slash', () => { it('URLs end with trailing slash', async () => { const data = await readXML(fixture.readFile('/sitemap-0.xml')); const urls = data.urlset.url; - assert.equal(urls[0].loc[0], 'http://example.com/one/'); + expect(urls[0].loc[0]).to.equal('http://example.com/one/'); }); }); @@ -41,7 +40,7 @@ describe('Trailing slash', () => { it('URLs do not end with trailing slash', async () => { const data = await readXML(fixture.readFile('/sitemap-0.xml')); const urls = data.urlset.url; - assert.equal(urls[0].loc[0], 'http://example.com/one'); + expect(urls[0].loc[0]).to.equal('http://example.com/one'); }); }); }); @@ -58,7 +57,7 @@ describe('Trailing slash', () => { it('URLs do no end with trailing slash', async () => { const data = await readXML(fixture.readFile('/sitemap-0.xml')); const urls = data.urlset.url; - assert.equal(urls[0].loc[0], 'http://example.com/one'); + expect(urls[0].loc[0]).to.equal('http://example.com/one'); }); describe('with base path', () => { before(async () => { @@ -73,7 +72,7 @@ describe('Trailing slash', () => { it('URLs do not end with trailing slash', async () => { const data = await readXML(fixture.readFile('/sitemap-0.xml')); const urls = data.urlset.url; - assert.equal(urls[0].loc[0], 'http://example.com/base/one'); + expect(urls[0].loc[0]).to.equal('http://example.com/base/one'); }); }); }); @@ -90,7 +89,7 @@ describe('Trailing slash', () => { it('URLs end with trailing slash', async () => { const data = await readXML(fixture.readFile('/sitemap-0.xml')); const urls = data.urlset.url; - assert.equal(urls[0].loc[0], 'http://example.com/one/'); + expect(urls[0].loc[0]).to.equal('http://example.com/one/'); }); describe('with base path', () => { before(async () => { @@ -105,7 +104,7 @@ describe('Trailing slash', () => { it('URLs end with trailing slash', async () => { const data = await readXML(fixture.readFile('/sitemap-0.xml')); const urls = data.urlset.url; - assert.equal(urls[0].loc[0], 'http://example.com/base/one/'); + expect(urls[0].loc[0]).to.equal('http://example.com/base/one/'); }); }); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ad70e8934d..a79a4a06f6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4175,7 +4175,7 @@ importers: version: 11.0.0 remark-shiki-twoslash: specifier: ^3.1.3 - version: 3.1.3 + version: 3.1.3(typescript@5.2.2) remark-toc: specifier: ^9.0.0 version: 9.0.0 @@ -4184,7 +4184,7 @@ importers: version: 11.0.4 vite: specifier: ^5.0.12 - version: 5.0.12 + version: 5.0.12(@types/node@18.19.4)(sass@1.69.6) packages/integrations/mdx/test/fixtures/css-head-mdx: dependencies: @@ -4600,6 +4600,12 @@ importers: astro-scripts: specifier: workspace:* version: link:../../../scripts + chai: + specifier: ^4.3.7 + version: 4.3.10 + mocha: + specifier: ^10.2.0 + version: 10.2.0 xml2js: specifier: 0.6.2 version: 0.6.2 @@ -7730,7 +7736,7 @@ packages: resolution: {integrity: sha512-kTwMUQ8xtAZaC4wb2XuLkPqFVBj2dNBueMQ89NWEuw87k2nLBbuafeG5cob/QEr6YduxIdTVUjix0MtC7mPlmg==} dependencies: '@typescript/vfs': 1.3.5 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) lz-string: 1.5.0 transitivePeerDependencies: - supports-color @@ -7739,7 +7745,7 @@ packages: /@typescript/vfs@1.3.4: resolution: {integrity: sha512-RbyJiaAGQPIcAGWFa3jAXSuAexU4BFiDRF1g3hy7LmRqfNpYlTQWGXjcrOaVZjJ8YkkpuwG0FcsYvtWQpd9igQ==} dependencies: - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) transitivePeerDependencies: - supports-color dev: true @@ -7747,7 +7753,7 @@ packages: /@typescript/vfs@1.3.5: resolution: {integrity: sha512-pI8Saqjupf9MfLw7w2+og+fmb0fZS0J6vsKXXrp4/PDXEFvntgzXmChCXC/KefZZS0YGS6AT8e0hGAJcTsdJlg==} dependencies: - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) transitivePeerDependencies: - supports-color dev: true @@ -8089,7 +8095,7 @@ packages: resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} engines: {node: '>= 6.0.0'} dependencies: - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) transitivePeerDependencies: - supports-color @@ -9177,17 +9183,6 @@ packages: ms: 2.1.3 dev: false - /debug@4.3.4: - resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} - engines: {node: '>=6.0'} - peerDependencies: - supports-color: '*' - peerDependenciesMeta: - supports-color: - optional: true - dependencies: - ms: 2.1.2 - /debug@4.3.4(supports-color@8.1.1): resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} engines: {node: '>=6.0'} @@ -10769,7 +10764,7 @@ packages: dependencies: '@tootallnate/once': 2.0.0 agent-base: 6.0.2 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) transitivePeerDependencies: - supports-color dev: true @@ -10779,7 +10774,7 @@ packages: engines: {node: '>= 6'} dependencies: agent-base: 6.0.2 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) transitivePeerDependencies: - supports-color @@ -12235,7 +12230,7 @@ packages: resolution: {integrity: sha512-o/sd0nMof8kYff+TqcDx3VSrgBTcZpSvYcAHIfHhv5VAuNmisCxjhx6YmxS8PFEpb9z5WKWKPdzf0jM23ro3RQ==} dependencies: '@types/debug': 4.1.12 - debug: 4.3.4 + debug: 4.3.4(supports-color@8.1.1) decode-named-character-reference: 1.0.2 devlop: 1.1.0 micromark-core-commonmark: 2.0.0 @@ -13975,7 +13970,7 @@ packages: unified: 11.0.4 vfile: 6.0.1 - /remark-shiki-twoslash@3.1.3: + /remark-shiki-twoslash@3.1.3(typescript@5.2.2): resolution: {integrity: sha512-4e8OH3ySOCw5wUbDcPszokOKjKuebOqlP2WlySvC7ITBOq27BiGsFlq+FNWhxppZ+JzhTWah4gQrnMjX3KDbAQ==} peerDependencies: typescript: '>3' @@ -13986,8 +13981,9 @@ packages: fenceparser: 1.1.1 regenerator-runtime: 0.13.11 shiki: 0.10.1 - shiki-twoslash: 3.1.2 + shiki-twoslash: 3.1.2(typescript@5.2.2) tslib: 2.1.0 + typescript: 5.2.2 unist-util-visit: 2.0.3 transitivePeerDependencies: - supports-color @@ -14340,7 +14336,7 @@ packages: resolution: {integrity: sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==} dev: true - /shiki-twoslash@3.1.2: + /shiki-twoslash@3.1.2(typescript@5.2.2): resolution: {integrity: sha512-JBcRIIizi+exIA/OUhYkV6jtyeZco0ykCkIRd5sgwIt1Pm4pz+maoaRZpm6SkhPwvif4fCA7xOtJOykhpIV64Q==} peerDependencies: typescript: '>3' @@ -14349,6 +14345,7 @@ packages: '@typescript/vfs': 1.3.4 fenceparser: 1.1.1 shiki: 0.10.1 + typescript: 5.2.2 transitivePeerDependencies: - supports-color dev: true @@ -15705,41 +15702,6 @@ packages: svgo: 3.2.0 dev: false - /vite@5.0.12: - resolution: {integrity: sha512-4hsnEkG3q0N4Tzf1+t6NdN9dg/L3BM+q8SWgbSPnJvrgH2kgdyzfVJwbR1ic69/4uMJJ/3dqDZZE5/WwqW8U1w==} - engines: {node: ^18.0.0 || >=20.0.0} - hasBin: true - peerDependencies: - '@types/node': ^18.0.0 || >=20.0.0 - less: '*' - lightningcss: ^1.21.0 - sass: '*' - stylus: '*' - sugarss: '*' - terser: ^5.4.0 - peerDependenciesMeta: - '@types/node': - optional: true - less: - optional: true - lightningcss: - optional: true - sass: - optional: true - stylus: - optional: true - sugarss: - optional: true - terser: - optional: true - dependencies: - esbuild: 0.19.11 - postcss: 8.4.33 - rollup: 4.9.2 - optionalDependencies: - fsevents: 2.3.3 - dev: true - /vite@5.0.12(@types/node@18.19.4)(sass@1.69.6): resolution: {integrity: sha512-4hsnEkG3q0N4Tzf1+t6NdN9dg/L3BM+q8SWgbSPnJvrgH2kgdyzfVJwbR1ic69/4uMJJ/3dqDZZE5/WwqW8U1w==} engines: {node: ^18.0.0 || >=20.0.0}