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

Your configFile is invalid [Cypress] #13883

Closed
shahraship opened this issue Dec 16, 2022 · 6 comments · Fixed by #13940
Closed

Your configFile is invalid [Cypress] #13883

shahraship opened this issue Dec 16, 2022 · 6 comments · Fixed by #13940
Assignees
Labels
outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx type: bug

Comments

@shahraship
Copy link

Current Behavior

Command I ran

nx component-test ng-app --verbose

Cypress Config file Content

import { defineConfig } from 'cypress';
import { nxComponentTestingPreset } from '@nrwl/angular/plugins/component-testing';

export default defineConfig({
component: nxComponentTestingPreset(__filename),
});

Expected Behavior

Expected to be able to run the component test

Github Repo

No response

Steps to Reproduce

Nx Report

Node : 16.15.1
   OS   : darwin x64
   npm  : 9.1.2
   
   nx : 15.3.0-rc.0
   @nrwl/angular : 15.3.3
   @nrwl/cypress : 15.3.3
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.3.3
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.3.3
   @nrwl/expo : Not Found
   @nrwl/express : 15.3.3
   @nrwl/jest : 15.3.3
   @nrwl/js : 15.3.3
   @nrwl/linter : 15.3.3
   @nrwl/nest : 15.3.3
   @nrwl/next : Not Found
   @nrwl/node : 15.3.3
   @nrwl/nx-cloud : 15.0.2
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 15.3.3
   @nrwl/react-native : Not Found
   @nrwl/rollup : 15.3.3
   @nrwl/schematics : Not Found
   @nrwl/storybook : 15.3.3
   @nrwl/web : 15.3.3
   @nrwl/webpack : 15.3.3
   @nrwl/workspace : 15.3.3
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:
         @ng-bootstrap/ng-bootstrap: 12.1.2
         @nguniversal/builders: 15.0.0
         @nguniversal/common: 15.0.0
         @nguniversal/express-engine: 15.0.0
         @nxext/stencil: 14.0.6
         ngx-spinner: 10.0.1

Failure Logs

Your configFile is invalid: /Users/me/Developer/monorepo/apps/ng-app/cypress.config.ts

It threw an error when required, check the stack trace below:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:372:5)
    at validateString (node:internal/validators:120:11)
    at Object.join (node:path:1172:7)
    at joinPathFragments (/Users/me/Developer/packages/nx/src/utils/path.ts:18:29)
    at normalizeBuildTargetOptions (/Users/me/Developer/monorepo/packages/angular/plugins/component-testing.ts:238:34)
    at nxComponentTestingPreset (/Users/me/Developer/monorepo/packages/angular/plugins/component-testing.ts:94:34)
    at Object.<anonymous> (/Users/me/Developer/monorepo/apps/ng-app/cypress.config.ts:5:38)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Module.m._compile (/Users/me/Library/Caches/Cypress/11.2.0/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:857:29)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/me/Library/Caches/Cypress/11.2.0/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:859:16)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at loadFile (/Users/me/Library/Caches/Cypress/11.2.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:89:14)
    at EventEmitter.<anonymous> (/Users/me/Library/Caches/Cypress/11.2.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:116:38)
    at EventEmitter.emit (node:events:527:28)
    at EventEmitter.emit (node:domain:475:12)
    at process.<anonymous> (/Users/me/Library/Caches/Cypress/11.2.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:33:22)
    at process.emit (node:events:527:28)
    at process.emit (node:domain:475:12)

Additional Information

No response

@FrozenPandaz FrozenPandaz added the scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx label Dec 20, 2022
@barbados-clemens
Copy link
Contributor

@shahraship can you share the project.json of the project that has component testing setup?

@barbados-clemens barbados-clemens self-assigned this Dec 20, 2022
@shahraship
Copy link
Author

{
"name": "ng-app",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"targets": {
"build": {
"executor": "@angular-devkit/build-angular:browser",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/ng-app/browser",
"index": "apps/ng-app/src/index.html",
"main": "apps/ng-app/src/main.ts",
"polyfills": "apps/ng-app/src/polyfills.ts",
"tsConfig": "apps/ng-app/tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"apps/ng-app/src/favicon.ico",
"apps/ng-app/src/assets",
"apps/ng-app/src/configs"
],
"styles": ["apps/ng-app/src/styles.scss"],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "apps/ng-app/src/environments/environment.ts",
"with": "apps/ng-app/src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"executor": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "ng-app:build:production"
},
"development": {
"browserTarget": "ng-app:build:development"
}
},
"defaultConfiguration": "development",
"options": {
"port": 7005,
"browserTarget": "ng-app:build:development"
}
},
"extract-i18n": {
"executor": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "ng-app:build"
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": [
"apps/ng-app/src//*.ts",
"apps/ng-app/src/
/*.html"
]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["{workspaceRoot}/coverage/apps/ng-app"],
"options": {
"jestConfig": "apps/ng-app/jest.config.ts",
"passWithNoTests": true
}
},
"server": {
"executor": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist/apps/ng-app/server",
"main": "apps/ng-app/server.ts",
"tsConfig": "apps/ng-app/tsconfig.server.json",
"inlineStyleLanguage": "scss"
},
"configurations": {
"production": {
"outputHashing": "media",
"fileReplacements": [
{
"replace": "apps/ng-app/src/environments/environment.ts",
"with": "apps/ng-app/src/environments/environment.prod.ts"
}
]
},
"development": {
"optimization": false,
"sourceMap": true,
"extractLicenses": false
}
},
"defaultConfiguration": "production",
"production": {
"outputHashing": "media",
"fileReplacements": [
{
"replace": "apps/ng-app/src/environments/environment.ts",
"with": "apps/ng-app/src/environments/environment.prod.ts"
}
]
},
"development": {
"optimization": false,
"sourceMap": true,
"extractLicenses": false
}
},
"serve-ssr": {
"executor": "@nguniversal/builders:ssr-dev-server",
"configurations": {
"development": {
"browserTarget": "ng-app:build:development",
"serverTarget": "ng-app:server:development"
},
"production": {
"browserTarget": "ng-app:build:production",
"serverTarget": "ng-app:server:production"
}
},
"defaultConfiguration": "development"
},
"component-test": {
"executor": "@nrwl/cypress:cypress",
"options": {
"cypressConfig": "apps/ng-app/cypress.config.ts",
"testingType": "component",
"skipServe": true,
"devServerTarget": "ng-app:build"
}
}
}
}

@barbados-clemens
Copy link
Contributor

it looks like your configuration is missing the sourceRoot property. It's usually set to apps/ng-app/src

this property is optional in the project.json schema, but used in angular component testing to pass to the angular under the hood. I'll update the preset to warn and just infer this value to ${appRoot}/src to prevent the error from stopping in the tracks.

but you can add the value to your project.json today and should get around the issue for now

@Karla-Reyes
Copy link

@barbados-clemens Is there any update on the issue? I got the same error "Your configFile is invalid" when running e2e test using nx. I have the src property defined in project.json like "sourceRoot": "apps/pojectA-e2e/src",

//cypress.config.ts file

import { defineConfig } from 'cypress';
import { nxE2EPreset } from '@nrwl/cypress/plugins/cypress-preset';

export default defineConfig({
e2e: nxE2EPreset(__dirname),
});

@barbados-clemens
Copy link
Contributor

@Karla-Reyes is was merged in #13940 make sure you're on the latest nx and cypress and if the issue persists open a new issue.

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants