tailwindcss/integrations/postcss/core-as-postcss-plugin.test.ts
Jordan Pittman dd9f656274
Fix failing postcss integration test (#19436)
This is what's causing the postcss test in #19434 to fail wanted to test
this in isolation without the version bumps
2025-12-12 09:38:08 -05:00

59 lines
1.5 KiB
TypeScript

import { describe } from 'vitest'
import { css, js, json, test } from '../utils'
const variantConfig = {
string: {
'postcss.config.js': js`
module.exports = {
plugins: {
tailwindcss: {},
},
}
`,
},
ESM: {
'postcss.config.mjs': js`
import tailwindcss from 'tailwindcss'
export default {
plugins: [tailwindcss()],
}
`,
},
CJS: {
'postcss.config.cjs': js`
let tailwindcss = require('tailwindcss')
module.exports = {
plugins: [tailwindcss()],
}
`,
},
}
describe.each(Object.keys(variantConfig))('%s', (variant) => {
test(
`can not use \`tailwindcss\` as a postcss module`,
{
fs: {
...variantConfig[variant],
'package.json': json`
{
"dependencies": {
"postcss": "^8",
"postcss-cli": "^10",
"tailwindcss": "workspace:^"
}
}
`,
'src/index.css': css`@import 'tailwindcss';`,
},
},
async ({ exec, expect }) => {
await expect(
exec('pnpm postcss src/index.css --output dist/out.css', undefined, { ignoreStdErr: true }),
).rejects.toThrowError(
`It looks like you're trying to use \`tailwindcss\` directly as a PostCSS plugin. The PostCSS plugin has moved to a separate package, so to continue using Tailwind CSS with PostCSS you'll need to install \`@tailwindcss/postcss\` and update your PostCSS configuration.`,
)
},
)
})