Skip to content

Commit

Permalink
Add Nuxt integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp-spiess committed Sep 4, 2024
1 parent e7ca667 commit 3d6da3d
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions integrations/vite/nuxt.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { expect } from 'vitest'
import { candidate, css, fetchStyles, html, json, retryAssertion, test, ts } from '../utils'

test(
'dev mode',
{
fs: {
'package.json': json`
{
"type": "module",
"dependencies": {
"@tailwindcss/vite": "workspace:^",
"nuxt": "^3.13.0",
"tailwindcss": "workspace:^",
"vue": "latest"
}
}
`,
'nuxt.config.ts': ts`
import tailwindcss from '@tailwindcss/vite'
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
vite: {
plugins: [tailwindcss()],
},
css: ['~/assets/css/main.css'],
devtools: { enabled: true },
compatibilityDate: '2024-08-30',
})
`,
'app.vue': html`
<template>
<div class="underline">Hello world!</div>
</template>
`,
'assets/css/main.css': css`@import 'tailwindcss';`,
},
},
async ({ fs, exec, getFreePort }) => {
let port = await getFreePort()
await exec(`pnpm nuxt dev --port ${port}`)

await retryAssertion(async () => {
let css = await fetchStyles(port, '/')
expect(css).toContain(candidate`underline`)
})

await fs.write(
'app.vue',
html`
<template>
<div class="underline font-bold">Hello world!</div>
</template>
`,
)
await retryAssertion(async () => {
let css = await fetchStyles(port)
expect(css).toContain(candidate`underline`)
expect(css).toContain(candidate`font-bold`)
})
},
)

0 comments on commit 3d6da3d

Please sign in to comment.