Nx: Cypress open fails with "Please provide an absolute path to a tsconfig.json as cypressConfig.env.tsConfig"

Created on 13 Aug 2019  路  7Comments  路  Source: nrwl/nx

Expected Behavior

It should use the existing tsconfig.json.

Current Behavior

It fails because there is no tsconfig.json defined in the config.

Failure Information (for bugs)

Error: Please provide an absolute path to a tsconfig.json as cypressConfig.env.tsConfig
    at preprocessTypescript (nx/myworkspace/node_modules/@nrwl/cypress/src/plugins/preprocessor.js:8:15)
    at module.exports (nx/myworkspace/apps/test-e2e/src/plugins/index.js:21:27)
    at Promise.try (Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:62:12)
    at tryCatcher (Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/method.js:39:29)
    at load (Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:61:7)
    at EventEmitter.ipc.on (Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:132:5)
    at emitOne (events.js:116:13)
    at EventEmitter.emit (events.js:211:7)
    at process.<anonymous> (Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:25:29)
    at emitTwo (events.js:126:13)
    at process.emit (events.js:214:7)
    at emit (internal/child_process.js:772:12)
    at _combinedTickCallback (internal/process/next_tick.js:141:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Generate a sample project for cypress with nx.
  2. Run npx cypress -P apps/test-e2e

Context

  • Nx: 8.4.8
Angular CLI: 8.1.1
Node: 10.15.3
OS: darwin x64
Angular: 8.2.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.801.1
@angular-devkit/build-angular     0.800.6
@angular-devkit/build-optimizer   0.800.6
@angular-devkit/build-webpack     0.800.6
@angular-devkit/core              8.1.1
@angular-devkit/schematics        8.1.1
@angular/cli                      8.1.1
@ngtools/webpack                  8.0.6
@schematics/angular               8.1.1
@schematics/update                0.801.1
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.30.0
bug

Most helpful comment

Is the any plan to change something here?
Using ng e2e test-e2e or cypress cli is better option than only ng e2e test-e2e

All 7 comments

Changing the plugin.js to set the tsconfig.json if not set works partial:

  on('file:preprocessor', () => {
    if (!config.env.tsConfig) {
      config.env.tsConfig = config.fileServerFolder + '/tsconfig.json';
    }
    return preprocessTypescript(config);
  });

It shows all tests now, but if you run a test now, it fails with another message:

GET /__/ 200 29.461 ms - -
GET /__cypress/runner/cypress_runner.css 200 22.230 ms - -
GET /__cypress/runner/cypress_runner.js 200 500.607 ms - -
GET /__cypress/static/favicon.ico 200 2.382 ms - -
GET /__cypress/iframes/integration/app.spec.ts 200 8.190 ms - 613
GET /__cypress/runner/fonts/fontawesome-webfont.woff2?v=4.7.0 200 4.772 ms - 77160
TypeError: path argument is required to res.sendFile
    at ServerResponse.sendFile (Cypress.app/Contents/Resources/app/packages/server/node_modules/express/lib/response.js:411:11)
    at tryCatcher (Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at ret (<anonymous>:14:23)
    at Cypress.app/Contents/Resources/app/packages/server/lib/controllers/spec.js:29:16
    at tryCatcher (Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:510:31)
    at Promise._settlePromise (Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:567:18)
    at Promise._settlePromise0 (Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:691:18)
    at Async._drainQueue (Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues (Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:789:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5)

GET /__cypress/tests?p=src/integration/app.spec.ts-218 200 6.698 ms - 165
HEAD / - - ms - -
HEAD / - - ms - -
HEAD / - - ms - -

I am using Cypress 3.4.1.

Hi @CSchulz, you can run e2e tests with ng e2e test-e2e, or you can use yarn/npm if you don't use a global ng bin.

We don't recommend using the cypress cli directly since will not have the correct config.

Is the any plan to change something here?
Using ng e2e test-e2e or cypress cli is better option than only ng e2e test-e2e

@CSchulz Did you have a workaround for this? I'm getting the same "path argument is required to res.sendFile" message when I run the test. Thanks!

Any news? Some issue in my project.

Hi @CSchulz, you can run e2e tests with ng e2e test-e2e, or you can use yarn/npm if you don't use a global ng bin.

We don't recommend using the cypress cli directly since will not have the correct config.

How do you do then to launch e2e test on a CI ? I haven't seen any example to do this and the only way I've seen personally is to try the official Cypress approach using cypress run command as the ng e2e fail on CI

Here is another use case: I wish to run tests against deployed app without building it first, e.g. by passing baseUrl

Was this page helpful?
0 / 5 - 0 ratings