-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d95bd9
commit cde0cc4
Showing
2 changed files
with
29 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
import { expect } from 'chai'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
const cssAssetReferenceRegExp = /_astro\/[A-Za-z0-9\-]+\.[a0-9a-f]{8}\.css/g | ||
const cssAssetReferenceRegExp = /_astro\/[A-Za-z0-9\-]+\.[a0-9a-f]{8}\.css/g; | ||
|
||
describe("When Vite's preloadModule polyfill is used", async () => { | ||
|
||
let fixture; | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/css-dangling-references/' | ||
}); | ||
root: './fixtures/css-dangling-references/', | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
it('there are no references to deleted CSS chunks', async () => { | ||
|
||
const fileNames = await fixture.readdir('/_astro/') | ||
const filePaths = fileNames.map(filename => '_astro/' + filename) | ||
|
||
const expectations = | ||
filePaths | ||
.filter(filePath => filePath.endsWith('js')) | ||
.map(async filePath => { | ||
const contents = await fixture.readFile(filePath) | ||
const cssReferences = contents.match(cssAssetReferenceRegExp) | ||
|
||
if (cssReferences === null) return | ||
|
||
expect(filePaths).to.contain.members(cssReferences, filePath + ' contains a reference to a deleted css asset: ' + cssReferences) | ||
}) | ||
|
||
await Promise.all(expectations) | ||
}) | ||
}) | ||
it('there are no references to deleted CSS chunks', async () => { | ||
const fileNames = await fixture.readdir('/_astro/'); | ||
const filePaths = fileNames.map((filename) => '_astro/' + filename); | ||
|
||
const expectations = filePaths | ||
.filter((filePath) => filePath.endsWith('js')) | ||
.map(async (filePath) => { | ||
const contents = await fixture.readFile(filePath); | ||
const cssReferences = contents.match(cssAssetReferenceRegExp); | ||
|
||
if (cssReferences === null) return; | ||
|
||
expect(filePaths).to.contain.members( | ||
cssReferences, | ||
filePath + ' contains a reference to a deleted css asset: ' + cssReferences | ||
); | ||
}); | ||
|
||
await Promise.all(expectations); | ||
}); | ||
}); |