add test
This commit is contained in:
parent
4eeca70fc6
commit
44c89b17e0
6 changed files with 48 additions and 0 deletions
8
packages/astro/test/fixtures/preloading/package.json
vendored
Normal file
8
packages/astro/test/fixtures/preloading/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@test/preloading",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
5
packages/astro/test/fixtures/preloading/src/pages/module1.astro
vendored
Normal file
5
packages/astro/test/fixtures/preloading/src/pages/module1.astro
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
<script>
|
||||
import { shared } from "../to-be-preloaded.js"
|
||||
console.log(shared)
|
||||
</script>
|
||||
<p></p>
|
5
packages/astro/test/fixtures/preloading/src/pages/module2.astro
vendored
Normal file
5
packages/astro/test/fixtures/preloading/src/pages/module2.astro
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
<script>
|
||||
import { shared } from "../to-be-preloaded.js"
|
||||
console.log(shared)
|
||||
</script>
|
||||
<p></p>
|
1
packages/astro/test/fixtures/preloading/src/to-be-preloaded.js
vendored
Normal file
1
packages/astro/test/fixtures/preloading/src/to-be-preloaded.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
export const shared = {}
|
23
packages/astro/test/preloading.test.js
Normal file
23
packages/astro/test/preloading.test.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { expect } from 'chai';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
import * as cheerio from 'cheerio';
|
||||
|
||||
describe('preloading', () => {
|
||||
/** @type {import('./test-utils.js').Fixture} */
|
||||
let fixture;
|
||||
|
||||
before(async () => {
|
||||
fixture = await loadFixture({
|
||||
root: './fixtures/preloading/',
|
||||
});
|
||||
await fixture.build()
|
||||
});
|
||||
|
||||
it('rendered page includes a link rel=modulepreload', async () => {
|
||||
const html = await fixture.readFile('/module1/index.html');
|
||||
const $ = cheerio.load(html);
|
||||
const link = $('link')[0];
|
||||
expect(link.attribs).to.deep.include({ rel: 'modulepreload' });
|
||||
expect(link.attribs.href).to.include('to-be-preloaded');
|
||||
});
|
||||
});
|
|
@ -3016,6 +3016,12 @@ importers:
|
|||
specifier: ^10.17.1
|
||||
version: 10.17.1
|
||||
|
||||
packages/astro/test/fixtures/preloading:
|
||||
dependencies:
|
||||
astro:
|
||||
specifier: workspace:*
|
||||
version: link:../../..
|
||||
|
||||
packages/astro/test/fixtures/public-base-404:
|
||||
dependencies:
|
||||
astro:
|
||||
|
|
Loading…
Reference in a new issue