mirror of
https://github.com/withastro/astro.git
synced 2025-02-03 22:29:08 -05:00
chore: move tests to node (#10115)
This commit is contained in:
parent
0f3d4ae30b
commit
40a2e03ffb
3 changed files with 24 additions and 21 deletions
|
@ -1,5 +1,6 @@
|
||||||
import { loadFixture } from './test-utils.js';
|
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';
|
import testAdapter from './test-adapter.js';
|
||||||
|
|
||||||
describe('Adapter', () => {
|
describe('Adapter', () => {
|
||||||
|
@ -18,8 +19,11 @@ describe('Adapter', () => {
|
||||||
});
|
});
|
||||||
await fixture.build();
|
await fixture.build();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
expect(e.toString()).to.contain(
|
assert.equal(
|
||||||
"The adapter my-ssr-adapter doesn't support the feature build.excludeMiddleware."
|
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();
|
await fixture.build();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
expect(e.toString()).to.contain(
|
assert.equal(
|
||||||
"The adapter my-ssr-adapter doesn't support the feature build.split."
|
e
|
||||||
|
.toString()
|
||||||
|
.includes("The adapter my-ssr-adapter doesn't support the feature build.split."),
|
||||||
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
|
@ -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 * as cheerio from 'cheerio';
|
||||||
import { loadFixture } from './test-utils.js';
|
import { loadFixture } from './test-utils.js';
|
||||||
|
|
||||||
|
@ -13,30 +14,24 @@ describe('Global Fetch', () => {
|
||||||
it('Is available in Astro pages', async () => {
|
it('Is available in Astro pages', async () => {
|
||||||
const html = await fixture.readFile('/index.html');
|
const html = await fixture.readFile('/index.html');
|
||||||
const $ = cheerio.load(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 () => {
|
it('Is available in Astro components', async () => {
|
||||||
const html = await fixture.readFile('/index.html');
|
const html = await fixture.readFile('/index.html');
|
||||||
const $ = cheerio.load(html);
|
const $ = cheerio.load(html);
|
||||||
expect($('#astro-component').text()).to.equal(
|
assert.equal($('#astro-component').text(), 'function', 'Fetch supported in .astro components');
|
||||||
'function',
|
|
||||||
'Fetch supported in .astro components'
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('Is available in non-Astro components', async () => {
|
it('Is available in non-Astro components', async () => {
|
||||||
const html = await fixture.readFile('/index.html');
|
const html = await fixture.readFile('/index.html');
|
||||||
const $ = cheerio.load(html);
|
const $ = cheerio.load(html);
|
||||||
expect($('#jsx').text()).to.equal('function', 'Fetch supported in .jsx');
|
assert.equal($('#jsx').text(), 'function', 'Fetch supported in .jsx');
|
||||||
expect($('#svelte').text()).to.equal('function', 'Fetch supported in .svelte');
|
assert.equal($('#svelte').text(), 'function', 'Fetch supported in .svelte');
|
||||||
expect($('#vue').text()).to.equal('function', 'Fetch supported in .vue');
|
assert.equal($('#vue').text(), 'function', 'Fetch supported in .vue');
|
||||||
});
|
});
|
||||||
it('Respects existing code', async () => {
|
it('Respects existing code', async () => {
|
||||||
const html = await fixture.readFile('/index.html');
|
const html = await fixture.readFile('/index.html');
|
||||||
const $ = cheerio.load(html);
|
const $ = cheerio.load(html);
|
||||||
expect($('#already-imported').text()).to.equal('function', 'Existing fetch imports respected');
|
assert.equal($('#already-imported').text(), 'function', 'Existing fetch imports respected');
|
||||||
expect($('#custom-declaration').text()).to.equal(
|
assert.equal($('#custom-declaration').text(), 'number', 'Custom fetch declarations respected');
|
||||||
'number',
|
|
||||||
'Custom fetch declarations respected'
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -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 * as cheerio from 'cheerio';
|
||||||
import { loadFixture } from './test-utils.js';
|
import { loadFixture } from './test-utils.js';
|
||||||
|
|
||||||
|
@ -15,6 +16,6 @@ describe('@fontsource/* packages', () => {
|
||||||
const $ = cheerio.load(html);
|
const $ = cheerio.load(html);
|
||||||
const assetPath = $('link').attr('href');
|
const assetPath = $('link').attr('href');
|
||||||
const css = await fixture.readFile(assetPath);
|
const css = await fixture.readFile(assetPath);
|
||||||
expect(css).to.contain('Montserrat');
|
assert.equal(css.includes('Montserrat'), true);
|
||||||
});
|
});
|
||||||
});
|
});
|
Loading…
Add table
Reference in a new issue