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

starting cypress and webpack #154

Open
andrei9669 opened this issue Mar 27, 2019 · 25 comments
Open

starting cypress and webpack #154

andrei9669 opened this issue Mar 27, 2019 · 25 comments

Comments

@andrei9669
Copy link

andrei9669 commented Mar 27, 2019

Is this a bug report or a feature request?

bug report

version

start-server-and-test: 1.7.12
cypress: 3.2.0

platform

win10

expected behavior

using scripts like these

"cy:start": "npm run open:src",
"cy:run": "cypress run",
"cy:test": "start-server-and-test cy:start http-get://localhost:3000 cy:run"

should work as described in README

actual behavior

It completes start script(builds source and then webpack) but it doesn't get any further than that

@bahmutov
Copy link
Owner

kind of missing details, can you run it in debug mode (see README)

@andrei9669
Copy link
Author

C:\~directory~>set DEBUG=start-server-and-test

C:\~directory~>npm run cy:test

> ~project~@1.0.0 cy:test C:~directory~
> start-server-and-test cy:start http-get://localhost:3000/ cy:run

starting server using command "npm run cy:start"
and when url "http-get://localhost:3000/" is responding
running tests using command "cy:run"
  start-server-and-test starting server, verbose mode? true +0ms
  start-server-and-test starting waitOn http-get://localhost:3000/ +45ms

> ~project~@1.0.0 cy:start C:\~directory~
> npm run open:src


> ~project~@1.0.0 open:src C:\~directory~
> babel-node tools/srcServer.js

child next [ { 'http-get://localhost:3000/': -999 } ]
wait-on(15068) waiting for: http-get://localhost:3000/
child complete
undefined { path: 'C:\\~directory~\\dist',
  publicPath: '/',
  filename: '[name].js',
  chunkFilename: '[name].js',
  library: '',
  hotUpdateFunction: 'webpackHotUpdate',
  jsonpFunction: 'webpackJsonp',
  libraryTarget: 'var',
  sourceMapFilename: '[file].map[query]',
  hotUpdateChunkFilename: '[id].[hash].hot-update.js',
  hotUpdateMainFilename: '[hash].hot-update.json',
  crossOriginLoading: false,
  chunkLoadTimeout: 120000,
  hashFunction: 'md5',
  hashDigest: 'hex',
  hashDigestLength: 20,
  devtoolLineToLine: false,
  strictModuleExceptionHandling: false }
child next []
child complete
child next []
child complete
child next []
child complete
........
child next []
child complete
webpack built c721a15d4d98a278ff50 in 86510ms
child next []
child complete
child next []
.....
child next []
child complete
Terminate batch job (Y/N)? y

it just starts looping indefinitely

@bahmutov
Copy link
Owner

bahmutov commented Mar 28, 2019 via email

@andrei9669
Copy link
Author

unfortunately not :/

@andrei9669
Copy link
Author

but could we find another way?

@mpacary
Copy link

mpacary commented Apr 4, 2019

Same problem here with Quasar framework which uses webpack under the hood.
Shows as well endless loops:

child complete
child next []
...

Even after server finished its loading.
Important note: seems related to HTTPS.
When my server starts on http://localhost:8080 instead of https://localhost:8080, things work as expected.

@mpacary
Copy link

mpacary commented Apr 4, 2019

After setting env var START_SERVER_AND_TEST_INSECURE to 1 (as stated in Readme), I get expected behavior 👍

wait-on(35176) exiting successfully found all: https://localhost:8080
  start-server-and-test waitOn finished successfully +54s
  start-server-and-test running test script command test +8ms

Maybe it would be great if this situation can be detected (server started but there is an SSL issue with wait-on) and a proper error message shown, instead of "no reaction".

@mpacary
Copy link

mpacary commented Apr 4, 2019

Works even better following the Readme entierely:

  • START_SERVER_AND_TEST_INSECURE back to 0
  • Using start-server-and-test server-task https-get://localhost:8080 test-task ("https-get" instead of "https" because of webpack-dev-server use)

Works like a charm as well (better option than setting something "insecure", even if it's only for checking that web server responds)

If there is a way to check automatically that webpack-dev-server is used, it would be great to switch automatically to "http-get" or "https-get" URLs for wait-on.

@andrei9669
Copy link
Author

@mpacary tried it but didn't work

@mpacary
Copy link

mpacary commented Apr 23, 2019

@andrei9669 did you try both approaches explained in my two last messages ?
BTW it seems that you use HTTP, not HTTPS ? is it still the case ?

@andrei9669
Copy link
Author

oh damn, I tried that env variable set to 0 and it works :D
thanks

@andrei9669
Copy link
Author

andrei9669 commented Apr 24, 2019

nvm, it worked once. after that "anomaly" it's not working again
and I'm using https-get

@mpacary
Copy link

mpacary commented Apr 24, 2019

Does it works with http-get instead of https-get? How to you set the env var before running start-server-and-test command?

@andrei9669
Copy link
Author

I'm using win 10 and I just search for "Edit environment variables for your account" and add it there like so
image
I tried 4 ways with https-get, http-get and insecure set to 1 or 0
when it worked, once, I used https-get and insecure set to 0, after changing from insecure 1

@mpacary
Copy link

mpacary commented Apr 24, 2019

Try changing env vars for system (instead of account), or typing directly in command line set START_SERVER_AND_TEST_INSECURE=1 right before running your start-server-and-test command

@andrei9669
Copy link
Author

andrei9669 commented Apr 24, 2019

okay, when I write set START_SERVER_AND_TEST_INSECURE=1 before I start testing, it works :)
how to make it run through npm without having to write it every time? (edit: you mentioned adding it to system var and it works)

Also if I have a test that fails I get a bunch of errors, is it normal?

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! project@1.0.0 cy:run: `cypress run`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project@1.0.0 cy:run script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\user\AppData\Roaming\npm-cache\_logs\2019-04-24T11_59_28_147Z-debug.log
{ Error: Command failed: C:\WINDOWS\system32\cmd.exe /q /s /c "npm run cy:run"
    at makeError (C:\project\node_modules\start-server-and-test\node_modules\execa\index.js:174:9)
    at Promise.all.then.arr (C:\project\node_modules\start-server-and-test\node_modules\execa\index.js:278:16)
    at processTicksAndRejections (internal/process/task_queues.js:86:5)
  code: 1,
  stdout: null,
  stderr: null,
  failed: true,
  signal: null,
  cmd: 'C:\\WINDOWS\\system32\\cmd.exe /q /s /c "npm run cy:run"',
  timedOut: false,
  killed: false }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! project@1.0.0 cy:test: `start-server-and-test open:src https-get://localhost:3000 cy:run`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project@1.0.0 cy:test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\user\AppData\Roaming\npm-cache\_logs\2019-04-24T11_59_28_390Z-debug.log

@mpacary
Copy link

mpacary commented Apr 24, 2019

Normal or not IDK, but it's certainly something you do not expect 😄. Please create another issue for this... If you do so, please tell exactly what command line you run to get this, what cy:start and cy:run do (from package.json tasks)
Also, what you get when you run directly npm run cy:run

@BramKaashoek
Copy link

As a heads up:

I had to run
start-test **start** http-get://localhost:3000 cypress:run-ci

Without the start I was getting an error when using http-get://: Error: missing url to wait on null.

@rodoabad
Copy link

If you're using proxy in dev server it will start to fail.

#163

@artivilla
Copy link

Tried quite a few of these variations. Not sure what I'm doing in correctly but can't get the test to run. Individually the commands run.

> DEBUG=start-server-and-test START_SERVER_AND_TEST_INSECURE=0 start-server-and-test start http:localhost:3000 cy:open

starting server using command "npm run start"
and when url "http:localhost:3000" is responding
running tests using command "npm run cy:open"
  start-server-and-test starting server with command "npm run start", verbose mode? true +0ms
  start-server-and-test starting waitOn http:localhost:3000 +5ms
  start-server-and-test wait-on options { resources: [ 'http:localhost:3000' ], interval: 2000, window: 1000, timeout: 300000, verbose: true, strictSSL: false, log: true } +0ms

> ui@0.1.0 start /Users/artichandok/Documents/bisontrails/webapp
> react-scripts start

Also tried START_SERVER_AND_TEST_INSECURE=1. I'm using the following:

"react-scripts": "^3.0.1",
"cypress": "^3.4.0",
"start-server-and-test": "^1.9.1",

with node v10.15.3 (npm v6.10.2)

@gowrishyadalam
Copy link

Getting below error when i run the cypress test cases

{ Error: Command failed with exit code 3: cypress run
at makeError (/home/User/Documents/loginpagetestcases/apm-react/node_modules/start-server-and-test/node_modules/execa/lib/error.js:56:11)
at handlePromise (/home/User/Documents/loginpagetestcases/apm-react/node_modules/start-server-and-test/node_modules/execa/index.js:114:26)
at process._tickCallback (internal/process/next_tick.js:68:7)
command: 'cypress run',
exitCode: 3,
signal: undefined,
signalDescription: undefined,
stdout: undefined,
stderr: undefined,
failed: true,
timedOut: false,
isCanceled: false,
killed: false }
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@bahmutov
Copy link
Owner

bahmutov commented Mar 23, 2020 via email

@gowrishyadalam
Copy link

yes.. three test cases failed. FYI, I know cypress return the exitcode:3 is this the real issue ??

@drenda
Copy link

drenda commented Apr 14, 2020

Hi, not sure my issue is related, but googling I came here.

I'm using Jenkins to run cypress and in my Job I've this error:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/opt/local/node/node-v12.16.1-linux-x64/bin/node',
1 verbose cli   '/opt/local/node/12/bin/npm',
1 verbose cli   'run',
1 verbose cli   'test'
1 verbose cli ]
2 info using npm@6.13.4
3 info using node@v12.16.1
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle test@0.0.6~pretest: test@0.0.6
6 info lifecycle test@0.0.6~test: test@0.0.6
7 verbose lifecycle test@0.0.6~test: unsafe-perm in lifecycle true
8 verbose lifecycle test@0.0.6~test: PATH: /opt/local/node/node-v12.16.1-linux-x64/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/var/lib/jenkins/workspace/angular test/node_modules/.bin:/opt/local/node/12/bin:/opt/local/java/8.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle test@0.0.6~test: CWD: /var/lib/jenkins/workspace/angular test
10 silly lifecycle test@0.0.6~test: Args: [ '-c', 'start-server-and-test start http://localhost:3030 cy:run' ]
11 silly lifecycle test@0.0.6~test: Returned: code: 1  signal: null
12 info lifecycle test@0.0.6~test: Failed to exec test script
13 verbose stack Error: test@0.0.6 test: `start-server-and-test start http://localhost:3030 cy:run`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/opt/local/node/node-v12.16.1-linux-x64/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:311:20)
13 verbose stack     at ChildProcess.<anonymous> (/opt/local/node/node-v12.16.1-linux-x64/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:311:20)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid test@0.0.6
15 verbose cwd /var/lib/jenkins/workspace/angular test
16 verbose Linux 4.15.0-96-generic
17 verbose argv "/opt/local/node/node-v12.16.1-linux-x64/bin/node" "/opt/local/node/12/bin/npm" "run" "test"
18 verbose node v12.16.1
19 verbose npm  v6.13.4
20 error code ELIFECYCLE
21 error errno 1
22 error test@0.0.6 test: `start-server-and-test start http://localhost:3030 cy:run`
22 error Exit status 1
23 error Failed at the test@0.0.6 test script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

I'm using cypress 4.3.0. For a detailed explanation I opened a stackOverflow post because I thought it was a configuration problem: https://stackoverflow.com/questions/61120755/jenkins-running-cypress-test-ends-up-with-timeout

Do you have any hint or workaround? I'm stuck with test automation :-\ Thanks

@wasiqkhan786
Copy link

wasiqkhan786 commented Oct 6, 2020

###Hi i am facing this issue tests successfully passed but at the end throw this error.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\MUK\AppData\Roaming\npm-cache_logs\2020-10-06T14_18_11_744Z-debug.log
Error: Command failed with exit code 2: npm run e2e
at makeError (D:\jenkins changes\fleetteam-repos\trunk\node_modules\start-server-and-test\node_modules\execa\lib\error.js:56:11)
at handlePromise (D:\jenkins changes\fleetteam-repos\trunk\node_modules\start-server-and-test\node_modules\execa\index.js:114:26)
at processTicksAndRejections (internal/process/task_queues.js:94:5) {
command: 'npm run e2e',
exitCode: 2,
signal: undefined,
signalDescription: undefined,
stdout: undefined,
stderr: undefined,
failed: true,
timedOut: false,
isCanceled: false,
killed: false
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ivu.fleet.map@ ci: start-server-and-test start-server 9000 e2e
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ivu.fleet.map@ ci script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\MUK\AppData\Roaming\npm-cache_logs\2020-10-06T14_18_12_102Z-debug.log

D:\jenkins changes\fleetteam-repos\trunk>

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

9 participants