I am trying to do some component testing with Cypress and I can't get it to work, I am always getting an error.
I think this is happening because Tailwind is not set up correctly. I tried following multiple guides online including the one from cypress themselves but I can't get it to work.
My test:
import React from 'react';
import MyComponent from "./page";
describe('render', () => {
it('renders', () => {
cy.mount(<MyComponent/>)
})
})
Component:
export default function MyComponent() {
return (
<div className="relative isolate">
<div className="mx-auto grid max-w-7xl grid-cols-1">
Hello
</div>
</div>
)
}
cypress.config.js:
const { defineConfig } = require('cypress');
module.exports = defineConfig({
component: {
supportFile: 'cypress/support/component.js',
devServer: {
framework: 'next',
bundler: 'webpack',
},
},
})
cypress/support/component.js:
import "tailwindcss/tailwind.css";
I also tried compiling css using tailwindcss -i src/app/globals.css -o src/index.css
and including index.css but that didn't change anything either.
I tried testing a component that does not use tailwind in any way and it works so the issue is definitely with tailwind.
What am I missing?
The app is set up using Next if that matters.