test: use semantic runIf and skipIf helpers (#7312)

This commit is contained in:
Daniel Roe 2022-09-07 10:55:03 +01:00 committed by GitHub
parent fc2be9ed42
commit 7ef028d4f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -369,8 +369,7 @@ describe('automatically keyed composables', () => {
})
})
if (!process.env.NUXT_TEST_DEV && !process.env.TEST_WITH_WEBPACK) {
describe('inlining component styles', () => {
describe.skipIf(process.env.NUXT_TEST_DEV || process.env.TEST_WITH_WEBPACK)('inlining component styles', () => {
it('should inline styles', async () => {
const html = await $fetch('/styles')
for (const style of [
@ -404,8 +403,7 @@ if (!process.env.NUXT_TEST_DEV && !process.env.TEST_WITH_WEBPACK) {
const html = await $fetch('/styles')
expect(html).toContain('{--client-only:"client-only"}')
})
})
}
})
describe('prefetching', () => {
it('should prefetch components', async () => {
@ -420,8 +418,7 @@ describe('prefetching', () => {
})
})
if (process.env.NUXT_TEST_DEV) {
describe('detecting invalid root nodes', () => {
describe.runIf(process.env.NUXT_TEST_DEV)('detecting invalid root nodes', () => {
it('should detect invalid root nodes in pages', async () => {
for (const path of ['1', '2', '3', '4']) {
const { consoleLogs } = await renderPage(joinURL('/invalid-root', path))
@ -439,15 +436,11 @@ if (process.env.NUXT_TEST_DEV) {
expect(consoleLogsWarns.length).toEqual(0)
}
})
})
}
})
describe('dynamic paths', () => {
if (process.env.NUXT_TEST_DEV) {
// TODO:
it.todo('dynamic paths in dev')
return
}
it.runIf(process.env.NUXT_TEST_DEV).todo('dynamic paths in dev')
it('should work with no overrides', async () => {
const html: string = await $fetch('/assets')
@ -457,12 +450,8 @@ describe('dynamic paths', () => {
}
})
it('adds relative paths to CSS', async () => {
if (process.env.TEST_WITH_WEBPACK) {
// Webpack injects CSS differently
return
}
it.skipIf(process.env.TEST_WITH_WEBPACK)('adds relative paths to CSS', async () => {
const html: string = await $fetch('/assets')
const urls = Array.from(html.matchAll(/(href|src)="(.*?)"|url\(([^)]*?)\)/g)).map(m => m[2] || m[3])
const cssURL = urls.find(u => /_nuxt\/assets.*\.css$/.test(u))