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

[developer experience] trying to run e2e tests locally errors (maybe because of space in username.) #3553

Open
pizzaisdavid opened this issue May 16, 2024 · 4 comments

Comments

@pizzaisdavid
Copy link
Contributor

I am a software developer using Windows and my username has a space.

How to reproduce:
Execute npm run test ci prod

Output:

$ npm run test ci prod

> test
> yarn workspace oa-cypress start ci prod

node:events:497
      throw er; // Unhandled 'error' event
      ^

Error: EPIPE: broken pipe, write
    at Socket._write (node:internal/net:61:18)
    at writeOrBuffer (node:internal/streams/writable:564:12)
    at _write (node:internal/streams/writable:493:10)
    at Writable.write (node:internal/streams/writable:502:10)
    at console.value (node:internal/console/constructor:304:16)
    at console.log (node:internal/console/constructor:379:26)
    at Object.http (file:///C:/Users/David%20-%20temp/AppData/Local/npm-cache/_npx/aab42732f01924e5/node_modules/serve/build/main.js:155:36)
    at run (file:///C:/Users/David%20-%20temp/AppData/Local/npm-cache/_npx/aab42732f01924e5/node_modules/serve/build/main.js:184:16)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:169:8)
    at emitErrorCloseNT (node:internal/streams/destroy:128:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -4047,
  syscall: 'write',
  code: 'EPIPE'
}

Node.js v20.13.1
 INFO  Accepting connections at http://localhost:3456

 HTTP  5/16/2024 10:03:52 PM 127.0.0.1 GET /

 HTTP  5/16/2024 10:03:52 PM 127.0.0.1 Returned 200 in 9 ms

Start tests
Running cypress with cmd: C:\Users\David - temp\Documents\community-platform\packages\cypress\node_modules\.bin\cypress run --record --env DUMMY_VAR=1 --key=62585f33-d688-47b7-acb3-6d1dca832065 --parallel --headless --browser chrome --group 1x-chrome --ci-build-id CccT00YI
testing complete with exit code 1
error 'C:\Users\David' is not recognized as an internal or external command,
operable program or batch file.

I guess I don't know for sure it is because of the space, but I would start with that assumption.

@pizzaisdavid
Copy link
Contributor Author

An addition:

In the description, I was running npm run test ci prod locally, and that is wrong, because it isn't the CI.

But running yarn test also results in a similar error:

$ yarn test
'C:\Users\David' is not recognized as an internal or external command,
operable program or batch file.

@pizzaisdavid
Copy link
Contributor Author

I am trying to fix this by adding the option to run the e2e tests inside of a docker container, this way avoiding any problems with my Windows username.

Currently, I have hit a bug when trying to use the cypress docker container:

  e2e-test-runner:
    # https://www.cypress.io/blog/2019/05/02/run-cypress-with-a-single-docker-command
    image: cypress/included:13.6.6
    depends_on:
      frontend:
        condition: service_healthy
    environment:
    - CYPRESS_baseUrl=http://frontend:3000
    working_dir: /e2e
    volumes:
    - ./packages/cypress:/e2e
    links:
    - frontend

Error:

e2e-test-runner-1  | Your configFile is invalid: /e2e/cypress.config.ts
e2e-test-runner-1  | 
e2e-test-runner-1  | It threw an error when required, check the stack trace below:
e2e-test-runner-1  | 
e2e-test-runner-1  | TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for 
/e2e/cypress.config.ts
e2e-test-runner-1  |     at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9)
e2e-test-runner-1  |     at defaultGetFormat (node:internal/modules/esm/get_format:203:36)    
e2e-test-runner-1  |     at defaultLoad (node:internal/modules/esm/load:143:22)
e2e-test-runner-1  |     at async ModuleLoader.load (node:internal/modules/esm/loader:409:7)  
e2e-test-runner-1  |     at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:291:45)
e2e-test-runner-1  |     at async link (node:internal/modules/esm/module_job:76:21)
e2e-test-runner-1 exited with code 1

My branch if anyone wants to investigate: https://github.com/ONEARMY/community-platform/compare/master...pizzaisdavid:community-platform:feat/e2e-tests-in-docker?expand=1

@benfurber
Copy link
Member

I think this might be windows specific as well? yarn test is what I'm running fine all day on mac.

@pizzaisdavid
Copy link
Contributor Author

✅ works:

$ pwd
/c/Users/test/Documents/community-platform
$ yarn test

❌ doesn't work:

$ pwd
/c/Users/test/Documents/lol lol lol/community-platform
$ yarn test
'C:\Users\test\Documents\lol' is not recognized as an internal or external command,
operable program or batch file.

I think it is because there is a space in the path.

On my normal account, my username is David - temp

To me, the ideal fix is introduce a way where cypress is ran inside of docker but still allowing the developer to see the Cypress user interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New / Under Discussion
Development

No branches or pull requests

2 participants