start-server-and-test icon indicating copy to clipboard operation
start-server-and-test copied to clipboard

starting cypress and webpack

Open andrei9669 opened this issue 5 years ago • 25 comments

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

andrei9669 avatar Mar 27 '19 06:03 andrei9669

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

bahmutov avatar Mar 27 '19 14:03 bahmutov

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

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

> [email protected] 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

> [email protected] cy:start C:\~directory~
> npm run open:src


> [email protected] 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

andrei9669 avatar Mar 28 '19 10:03 andrei9669

Yeah seems something about it that wait-on does not recognize :( is this repo public so I can run it myself?

Sent from my iPhone

On Mar 28, 2019, at 06:36, Andrei [email protected] wrote:

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

C:~directory~>npm run cy:test

[email protected] 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

[email protected] cy:start C:~directory~ npm run open:src

[email protected] 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

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

bahmutov avatar Mar 28 '19 13:03 bahmutov

unfortunately not :/

andrei9669 avatar Mar 29 '19 07:03 andrei9669

but could we find another way?

andrei9669 avatar Mar 29 '19 19:03 andrei9669

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 avatar Apr 04 '19 10:04 mpacary

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 avatar Apr 04 '19 10:04 mpacary

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.

mpacary avatar Apr 04 '19 10:04 mpacary

@mpacary tried it but didn't work

andrei9669 avatar Apr 23 '19 10:04 andrei9669

@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 ?

mpacary avatar Apr 23 '19 18:04 mpacary

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

andrei9669 avatar Apr 24 '19 04:04 andrei9669

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

andrei9669 avatar Apr 24 '19 05:04 andrei9669

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

mpacary avatar Apr 24 '19 08:04 mpacary

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

andrei9669 avatar Apr 24 '19 08:04 andrei9669

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

mpacary avatar Apr 24 '19 10:04 mpacary

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! [email protected] cy:run: `cypress run`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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! [email protected] 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 [email protected] 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

andrei9669 avatar Apr 24 '19 12:04 andrei9669

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

mpacary avatar Apr 24 '19 18:04 mpacary

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.

BramKaashoek avatar May 16 '19 13:05 BramKaashoek

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

https://github.com/bahmutov/start-server-and-test/issues/163

rodoabad avatar May 16 '19 15:05 rodoabad

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

> [email protected] 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)

artivilla avatar Jul 29 '19 06:07 artivilla

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.

gowrishyadalam avatar Mar 23 '20 16:03 gowrishyadalam

Can you paste the full output log? Did any of the cypress tests fail?

Sent from my iPhone

On Mar 23, 2020, at 12:54, gowrishyadalam [email protected] wrote:

 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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

bahmutov avatar Mar 23 '20 17:03 bahmutov

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

gowrishyadalam avatar Mar 24 '20 11:03 gowrishyadalam

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 [email protected]
3 info using [email protected]
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle [email protected]~pretest: [email protected]
6 info lifecycle [email protected]~test: [email protected]
7 verbose lifecycle [email protected]~test: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~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 [email protected]~test: CWD: /var/lib/jenkins/workspace/angular test
10 silly lifecycle [email protected]~test: Args: [ '-c', 'start-server-and-test start http://localhost:3030 cy:run' ]
11 silly lifecycle [email protected]~test: Returned: code: 1  signal: null
12 info lifecycle [email protected]~test: Failed to exec test script
13 verbose stack Error: [email protected] 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 [email protected]
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 [email protected] test: `start-server-and-test start http://localhost:3030 cy:run`
22 error Exit status 1
23 error Failed at the [email protected] 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

drenda avatar Apr 14 '20 16:04 drenda

###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>

wasiqkhan786 avatar Oct 06 '20 14:10 wasiqkhan786