Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CoffeeScript 2 support #663

Closed
laurentpayot opened this issue Sep 19, 2017 · 8 comments
Closed

CoffeeScript 2 support #663

laurentpayot opened this issue Sep 19, 2017 · 8 comments
Milestone

Comments

@laurentpayot
Copy link

laurentpayot commented Sep 19, 2017

  • Operating System: Ubuntu 17.04
  • Cypress Version: 0.20.1
  • Browser Version: Chrome 62, Chromium 60, Electron 53

Is this a Feature or Bug?

Feature

Current behavior:

Cypress does not support CoffeeScript 2 syntax (especially the await keyword), that was released a few days ago.

To fix this in Cypress server I replaced CS1 with CS2 (see below how to reproduce).
Then everything was working fine with my CS2 tests, but only using the Cypress app (via cypress open). Via cypress run I got weird errors with electron, chrome and chromium browsers (see stack trace below ).

Desired behavior:

CoffeeScript 2 tests working "out of the box" after a fresh Cypress install, with cypress open as well as cypress run.

How to reproduce:

In Cypress server I replaced CS1 with CS2 like so:

cd node_modules/cypress/dist/Cypress/resources/app/packages/server/
npm i coffeescript@next
cd node_modules
mv coffee-script/ coffee-script_V1
ln -s coffeescript/ coffee-script

Additional Info (images, stack traces, etc)

Using cypress run with CoffeeScript 2, I get the following error:

npx cypress run --browser electron --config baseUrl=http://localhost:5000

Started video recording: /home/laurent/myproject/cypress/videos/k38ej.mp4

  (Tests Starting)


  1) An uncaught error was detected outside of a test

  0 passing (236ms)
  1 failing

  1)  An uncaught error was detected outside of a test:
     Uncaught SyntaxError: missing ) after argument list

Cypress could not associate this error to any specific test.

We dynamically generated a new test to display this failure.
@brian-mann
Copy link
Member

Can you provide an example of your test code?

@laurentpayot
Copy link
Author

Sure.

describe("dummy tests:", ->

  context("foo:", ->

    it.only "should return 4", ->
      # result = 2 + 2 # no error
      result = await Promise.resolve(2 + 2) # generates an error with `cypress run`
      expect      result
      .to.equal    4

  )
)

@brian-mann
Copy link
Member

Just curious - are you writing unit tests in Cypress? Why would you use the await syntax with Cypress tests?

@laurentpayot
Copy link
Author

laurentpayot commented Sep 19, 2017

Yes I write "not so unit" tests in Cypress. I use Firebase and I need to test some promise-returning CRUD functions I wrote that are using Firebase calls. That way I can test database security rules located on the Firebase cloud side.
All these CRUD tests do not need UI so I was simply using mocha, but I moved them inside Cypress because:

  1. it is nice to have all the tests in a single reporter
  2. mocha CLI test environment was node, not the browser as with Cypress (am I right?)

Also to use Firebase node admin functionalities (test users creation on the fly, JWT generation etc.) I had to set an express server up that I'm calling inside Cypress tests via POST fetch requests . Let me know if you see a better alternative…

@brian-mann
Copy link
Member

brian-mann commented Sep 26, 2017

Transpiling to CS2 will soon be supported by the plugins / extensions API.

@laurentpayot
Copy link
Author

#684 is really epic. Cypress is getting better and better 👍

@brian-mann brian-mann added this to the 1.1.0 milestone Nov 20, 2017
@brian-mann
Copy link
Member

You can now do this yourself by modifying the browserify options and add your own coffeescript 2 support.

Fixed by #888.

@brian-mann
Copy link
Member

Fixed in 1.1.0.

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

No branches or pull requests

2 participants