cypress-dark icon indicating copy to clipboard operation
cypress-dark copied to clipboard

Doesn't seem to work with Typescript

Open brandonb927 opened this issue 7 years ago • 7 comments

Bug Report

When running a spec, I see this error pop up for every test.

I've added require('cypress-dark') to my cypress/support/index.ts to no avail.

  • Cypress 3.1.0
  • macOS 10.14
  • Dark mode is available in Cypress test runner
  • Receive an error running any spec

brandonb927 avatar Oct 22 '18 21:10 brandonb927

@brandonb927 thank you for trying this out :)

So I have JS spec example (without TS transpile) here https://github.com/bahmutov/cypress-dark-example and it works as is. To find where the problem happens (since there are some hoops to jump to get to the "right" CSS file), could you modify that project so I can see what happens in your situation? and if you want to fix https://github.com/bahmutov/cypress-dark/blob/master/src/utils.js#L7 then it would be even better :)

bahmutov avatar Oct 23 '18 14:10 bahmutov

@bahmutov thanks, I downloaded the project and have a minimal project for ts compilation working. I will push up what I have to my fork when I get a chance :)

brandonb927 avatar Oct 23 '18 22:10 brandonb927

I saw you forked it - looking forward, don’t rush cause I don’t know when I will have time to get to it unfortunately

Sent from my iPhone

On Oct 24, 2018, at 00:41, Brandon Brown [email protected] wrote:

@bahmutov thanks, I downloaded the project and have a minimal project for ts compilation working. I will push up what I have to my fork when I get a chance :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

bahmutov avatar Oct 23 '18 22:10 bahmutov

Any update with this issue? I am running into the exact same issue and would like to see how this can be accomplished.

Harvnlenny avatar Jan 26 '19 19:01 Harvnlenny

I've yet to actually dive into this as it's super low priority for me. Feel free to take it on!

brandonb927 avatar Jan 26 '19 19:01 brandonb927

This issue seems totally related to https://github.com/cypress-io/cypress/issues/4352

For a simple workaround you can modifiy the themeFileName passed into cy.readFile() inside of /src/utils.js to not be a relative path.

So cy.readFile("/node_modules/cypress-dark/src/dark.css") fails

Where cy.readFile("node_modules/cypress-dark/src/dark.css") succeeds

I would love to be able to use dark theme out of the box with newer versions of Cypress.

The problem of this issue is nit TS, but that node_modules is not a sibling to cypress directory https://github.com/bahmutov/cypress-dark/issues/160

seyfer avatar Dec 23 '19 10:12 seyfer