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

"cypress run" command hangs indefinitely when unit testing Aurelia components #3082

Closed
silbinarywolf opened this issue Jan 8, 2019 · 6 comments

Comments

@silbinarywolf
Copy link
Contributor

silbinarywolf commented Jan 8, 2019

Current behavior:

When I test my Aurelia components in Cypress, my unit testing library code executes fine if I run it manually via cypress open. However if I use cypress run, none of the tests within the files are found. It's as if it's hit some kind of error and just hangs until it times out. It finds the actual *.test.ts files, it just can't see any tests within them.

I think... it's hitting the "taskTimeout" or something?

Desired behavior:

I expect cypress run to work exactly like cypress open but be non-interactive or at the very least for Cypress to inform me of what error is occurring (if one is).

Steps to reproduce: (app code and test code)

  • Pull down this repo: silbinarywolf/cypress-aurelia-unit-test@db6bbe2
  • Run npm install
  • Run cypress open and click "Run all specs". All the tests should get a tick and pass.
  • Now try and run cypress run. You'll notice it just hangs for a long while and eventually nothing happens. If you investigate and look at the *.mp4 files, you'll most likely see nothing happen in about 5-10 seconds. There was 1 rare instance where it showed the error message "No test cases found" or similar.

You can see the cypress run step in Travis here. The tests say they're passing... but it's seemingly not actually executing them.

Versions

  • Cypress 3.1.4
  • Windows 10
@jennifer-shehane
Copy link
Member

My tests actually did eventually finish and exit, but it look an unreasonable amount of time.

Truncated version of logs found when running DEBUG=cypress:* cypress run:

This looks a bit weird, concerning a video capture stderr:

  cypress:server:video capture stderr log { message: 'ffmpeg version N-91158-g63c4a4b0d6-tessus Copyright (c) 2000-2018 the FFmpeg developers' } +4ms
  cypress:server:video capture stderr log { message: '  built with Apple LLVM version 9.1.0 (clang-902.0.39.1)' } +0ms
  cypress:server:video capture stderr log { message: '  configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-version3 --pkg-config-flags=--static --disable-ffplay' } +0ms
  cypress:server:video capture stderr log { message: '  libavutil      56. 18.102 / 56. 18.102' } +0ms
  cypress:server:video capture stderr log { message: '  libavcodec     58. 19.104 / 58. 19.104' } +0ms
  cypress:server:video capture stderr log { message: '  libavformat    58. 17.100 / 58. 17.100' } +0ms
  cypress:server:video capture stderr log { message: '  libavdevice    58.  4.100 / 58.  4.100' } +1ms
  cypress:server:video capture stderr log { message: '  libavfilter     7. 24.100 /  7. 24.100' } +0ms
  cypress:server:video capture stderr log { message: '  libswscale      5.  2.100 /  5.  2.100' } +0ms
  cypress:server:video capture stderr log { message: '  libswresample   3.  2.100 /  3.  2.100' } +0ms
  cypress:server:video capture stderr log { message: '  libpostproc    55.  2.100 / 55.  2.100' } +0ms

Also these webpack errors, which I suspect to be the core problem:

  cypress:webpack warnings for /Users/jennifer/Library/Application Support/Cypress/cy/production/projects/cypress-aurelia-unit-test-765209490dbf5537982383c32ca06287/bundles/cypress/integration/unit/box-component.test.ts +4s
  cypress:webpack [ 'configuration\nThe \'mode\' option has not been set, webpack will fallback to \'production\' for this value. Set \'mode\' option to \'development\' or \'production\' to enable defaults for each environment.\nYou can also set it to \'none\' to disable any default behavior. Learn more: https://webpack.js.org/concepts/mode/',
  cypress:webpack   'asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).\nThis can impact web performance.\nAssets: \n  box-component.test.ts (832 KiB)',
  cypress:webpack   'entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.\nEntrypoints:\n  main (832 KiB)\n      box-component.test.ts\n',
  cypress:webpack   'webpack performance recommendations: \nYou can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.\nFor more info visit https://webpack.js.org/guides/code-splitting/' ] +0ms
  cypress:webpack finished bundling /Users/jennifer/Library/Application Support/Cypress/cy/production/projects/cypress-aurelia-unit-test-765209490dbf5537982383c32ca06287/bundles/cypress/integration/unit/box-component.test.ts +0ms
  cypress:webpack - compile finished for /Users/jennifer/Dev/cypress-aurelia-unit-test/cypress/integration/unit/box-component.test.ts +1ms

Messages:

asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
box-component.test.ts (832 KiB)

entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
main (832 KiB)
box-component.test.ts

webpack performance recommendations:
You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
For more info visit https://webpack.js.org/guides/code-splitting/

cypress/integration/plugins/index.js

const wp = require('@cypress/webpack-preprocessor');
const path = require('path');
const webpackOptions = require(path.resolve(__dirname, '../../webpack.config'));

if (!webpackOptions) {
  throw new Error('Missing webpack options.');
}

module.exports = (on) => {
  const options = {
    webpackOptions: webpackOptions,
  }
  on('file:preprocessor', wp(options))
}

@jennifer-shehane jennifer-shehane added topic: plugins ⚙️ stage: needs investigating Someone from Cypress needs to look at this and removed stage: investigating Someone from Cypress is looking into this labels Jan 8, 2019
@chrisbreiding chrisbreiding self-assigned this Jan 8, 2019
@silbinarywolf
Copy link
Contributor Author

Your response was insanely quick! Thank you for your quick reply!

I'm not convinced the Webpack warnings would be the cause unless cypress run has some alternate behaviour regarding how it handles console.warn. These warnings also get thrown if you run cypress open.

@silbinarywolf
Copy link
Contributor Author

silbinarywolf commented Jan 9, 2019

@chrisbreiding I've been doing some work and stumbled upon the fact that "cypress open" will not work if I have the following in my cypress.json.

{
  "watchForFileChanges": false
}

As an FYI, I discovered this when trying to use the following module with Cypress:

(Because it writes out a file, Cypresses watcher picks up the changes and gets caught in an infinite loop!)

EDIT: The build times are just longer in this mode for reasons I'm not sure about yet.

@silbinarywolf
Copy link
Contributor Author

silbinarywolf commented Jan 10, 2019

@jennifer-shehane In regards to this issue, am I able to get an ETA on when you guys will be able to look into it? I understand that you all most likely have higher priorities but I just need to get a rough idea on when this would be looked into. (ie. in a month? 3 months? 6 months? 1 year?)

Just so I know when I can set aside resources to bring the fixes upstream into my projects :)

P.S. Thanks again for your support :)

@chrisbreiding
Copy link
Contributor

I tracked this down to a bug in @cypress/webpack-preprocessor. It was doing things in run mode that it should only have been doing in interactive/watch mode.

It's been fixed in @cypress/webpack-preprocessor v4.0.3, so your tests should run properly if you update it.

By the way, when I did get them to run, I noticed one test failing in Electron (which is the browser used in run mode) that's not failing in Chrome. I think it must be related to the version of Electron shipped with Cypress being old. The Electron version will be upgraded in Cypress 4, so keep an eye out for that.

@silbinarywolf
Copy link
Contributor Author

silbinarywolf commented Jan 12, 2019

Thank you and thanks also for the heads up on the failing test!
I didn't expect such a quick turn-around! I appreciate it!

@jennifer-shehane jennifer-shehane removed stage: needs investigating Someone from Cypress needs to look at this labels Jan 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants