tailwindcss/integrations/vite/nuxt.test.ts
Robin Malfait 38652a4638
migrate to pnpm v11 (#20273)
This PR bumps the repo to pnpm v11 (from v9). 

I kept running into weird Windows specific issues for the integration
tests due to some shims but they all pass right now.

Bumping to pnpm v11 also meant that everything is driven by a
`pnpm-workspace.yaml` file, and changes applied via the `pnpm` field in
the `package.json` don't work anymore.

This also moved the `node-linker` setup that was defined in the `.npmrc`
file for the wasm oxide build into the `pnpm-workspace.yaml` file.
Ideally this is scoped to just this package, but I couldn't get that to
work, so it's applied to all packages right now.

[ci-all]
2026-06-25 19:14:10 +02:00

117 lines
2.7 KiB
TypeScript

import {
candidate,
css,
fetchStyles,
getRandomPort,
html,
json,
retryAssertion,
test,
ts,
yaml,
} from '../utils'
const SETUP = {
fs: {
'package.json': json`
{
"type": "module",
"dependencies": {
"@tailwindcss/vite": "workspace:^",
"nuxt": "3.16.0",
"nitropack": "2.11.0",
"tailwindcss": "workspace:^",
"vue": "latest"
}
}
`,
'pnpm-workspace.yaml': yaml`
#
overrides:
nuxi: 3.28.0
`,
'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';`,
},
}
test('dev mode', SETUP, async ({ fs, spawn, expect }) => {
let process = await spawn('pnpm nuxt dev', {
env: {
TEST: 'false', // VERY IMPORTANT OTHERWISE YOU WON'T GET OUTPUT
NODE_ENV: 'development',
},
})
let url = ''
await process.onStdout((m) => {
let match = /Local:\s*(http.*)\//.exec(m)
if (match) url = match[1]
return Boolean(url)
})
await process.onStdout((m) => m.includes('server warmed up in'))
await retryAssertion(async () => {
let css = await fetchStyles(url)
expect(css).toContain(candidate`underline`)
})
await retryAssertion(async () => {
await fs.write(
'app.vue',
html`
<template>
<div class="underline font-bold">Hello world!</div>
</template>
`,
)
let css = await fetchStyles(url)
expect(css).toContain(candidate`underline`)
expect(css).toContain(candidate`font-bold`)
})
})
test('build', SETUP, async ({ spawn, exec, expect }) => {
await exec('pnpm nuxt build')
// The Nuxt preview server does not automatically assign a free port if 3000
// is taken, so we use a random port instead.
let port = await getRandomPort()
let process = await spawn(`pnpm nuxt preview --port ${port}`, {
env: {
TEST: 'false',
NODE_ENV: 'development',
},
})
let url = ''
await process.onStdout((m) => {
let match = /Listening on\s*(http.*)\/?/.exec(m)
if (match) url = match[1].replace('http://[::]', 'http://127.0.0.1')
return m.includes('Listening on')
})
await retryAssertion(async () => {
let css = await fetchStyles(url)
expect(css).toContain(candidate`underline`)
})
})