Nx can't find configuration for task when I run tests

567 views Asked by At

I am using nx, I have this repo named access-zone-e2e, it was generated automatically when I created the repo access-zone, when I was creating it I use also the --js flag.

So, my problem is that when I run this command: npx nx run access-zone-be-e2e:test I get the following error: Cannot find configuration for task access-zone-be-e2e:test. The files were generated automatically so I don't understand why what configuration is missing.

Here is the jest.config.js :

/* eslint-disable */
export default {
  displayName: 'access-zone-be-e2e',
  preset: '../../jest.preset.js',
  globalSetup: '<rootDir>/src/support/global-setup.js',
  globalTeardown: '<rootDir>/src/support/global-teardown.js',
  setupFiles: ['<rootDir>/src/support/test-setup.js'],
  testEnvironment: 'node',
  transform: {
    '^.+\\.[tj]s$': [
      'ts-jest',
      {
        tsconfig: '<rootDir>/tsconfig.spec.json',
      },
    ],
  },
  moduleFileExtensions: ['ts', 'js', 'html'],
  coverageDirectory: '../../coverage/access-zone-be-e2e',
};

This is the project.json:

{
  "name": "access-zone-be-e2e",
  "$schema": "../../node_modules/nx/schemas/project-schema.json",
  "implicitDependencies": [
    "access-zone-be"
  ],
  "projectType": "application",
  "targets": {
    "e2e": {
      "executor": "@nx/jest:jest",
      "outputs": [
        "{workspaceRoot}/coverage/{e2eProjectRoot}"
      ],
      "options": {
        "jestConfig": "apps/access-zone-be-e2e/jest.config.js",
        "passWithNoTests": true
      }
    },
    "lint": {
      "executor": "@nx/eslint:lint",
      "outputs": [
        "{options.outputFile}"
      ],
      "options": {
        "lintFilePatterns": [
          "apps/access-zone-be-e2e/**/*.{js,ts}"
        ]
      }
    }
  }
}

This is the nx.json file in the outer folder:

{
  "$schema": "./node_modules/nx/schemas/nx-schema.json",
  "npmScope": "nx-eas",
  "affected": {
    "defaultBase": "master"
  },
  "tasksRunnerOptions": {
    "default": {
      "runner": "nx/tasks-runners/default",
      "options": {
        "cacheableOperations": ["build", "lint", "test", "e2e"]
      }
    }
  },
  "targetDefaults": {
    "build": {
      "dependsOn": ["^build"],
      "inputs": ["production", "^production"]
    },
    "e2e": {
      "inputs": ["default", "^production"]
    },
    "lint": {
      "inputs": [
        "default",
        "{workspaceRoot}/.eslintrc.json",
        "{workspaceRoot}/.eslintignore"
      ]
    },
    "test": {
      "inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"]
    }
  },
  "namedInputs": {
    "default": ["{projectRoot}/**/*", "sharedGlobals"],
    "production": [
      "default",
      "!{projectRoot}/.eslintrc.json",
      "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
      "!{projectRoot}/tsconfig.spec.json",
      "!{projectRoot}/jest.config.[jt]s"
    ],
    "sharedGlobals": ["{workspaceRoot}/babel.config.json"]
  },
  "generators": {
    "@nx/react": {
      "application": {
        "style": "scss",
        "linter": "eslint",
        "bundler": "webpack",
        "babel": true
      },
      "component": {
        "style": "scss"
      },
      "library": {
        "style": "scss",
        "linter": "eslint",
        "unitTestRunner": "jest"
      }
    }
  }
}

How can I fix this error? What should I change or add?

0

There are 0 answers