mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
These tests won't ever be run in a deployed environment, so this removes `skipDeployment` so it's easier to grok which tests are intentionally disabled because they don't work when deployed.
33 lines
776 B
TypeScript
33 lines
776 B
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
describe('remove-unused-imports', () => {
|
|
const { next, skipped } = nextTestSetup({
|
|
files: __dirname,
|
|
})
|
|
|
|
if (skipped) {
|
|
return
|
|
}
|
|
|
|
it('should remove unused imports', async () => {
|
|
const browser = await next.browser('/')
|
|
let scripts = await browser.elementsByCss('script[src]')
|
|
|
|
expect(
|
|
(
|
|
await Promise.all(
|
|
scripts.map(async (el) => {
|
|
const src = await el.getAttribute('src')
|
|
const res = await next.fetch(src)
|
|
const code = await res.text()
|
|
if (code.includes('This is a big library.')) {
|
|
return src
|
|
}
|
|
return false
|
|
})
|
|
)
|
|
).filter((item) => item)
|
|
).toBeEmpty()
|
|
})
|
|
})
|