Skip to content

NextJS import global stylesheets in all components #16294

Discussion options

You must be logged in to vote

This hack works better for me than the styles components (which keeps showing a warning because @import)

cypress/helpers/mountWithGlobalStyles.tsx

import { mount as cyMount } from '@cypress/react'
import '@cypress/react/global.css'

export function mount(tsx: Parameters<typeof cyMount>[0], options?: Parameters<typeof cyMount>[1]) {
  return cyMount(tsx, options)
}

styles/global.css

@import './normalize.css';
@import './general.css';
@import './typography.css';
$ yarn add -D copyfiles

package.json

  "scripts": {
    ...
    "cy:open-ct": "yarn copyfiles -EV './styles/*.css' ./node_modules/@cypress/react && cypress open-ct",
    ...

Replies: 5 comments 26 replies

Comment options

You must be logged in to vote
5 replies
@alfupe
Comment options

@Norfeldt
Comment options

@Norfeldt
Comment options

@lmiller1990
Comment options

@Norfeldt
Comment options

Comment options

You must be logged in to vote
12 replies
@Norfeldt
Comment options

@lmiller1990
Comment options

@Norfeldt
Comment options

@lmiller1990
Comment options

@Norfeldt
Comment options

Comment options

You must be logged in to vote
7 replies
@Vadorequest
Comment options

@Norfeldt
Comment options

@Norfeldt
Comment options

@Vadorequest
Comment options

@Norfeldt
Comment options

Comment options

You must be logged in to vote
1 reply
@Norfeldt
Comment options

Answer selected by Norfeldt
Comment options

You must be logged in to vote
1 reply
@EandrewJones
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants