nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.72k stars 2.37k forks source link

Jest project schematic: Preset ../../../jest.config.js not found. #739

Closed ernie58 closed 6 years ago

ernie58 commented 6 years ago

I tried the Jest and Jest project schematic on an existing project, but I can't run the tests afterwards.
I've updated via ng update @nrwl/schematics@6.3.0

Then these where the steps I have followed:

ng generate jest
    CREATE jest.config.js (312 bytes)
    UPDATE package.json (2584 bytes)
    up to date in 7.283s
ng generate jest-project --project polpo-classroom-web
    CREATE apps/polpo-classroom-web/jest.config.js (157 bytes)
    CREATE apps/polpo-classroom-web/tsconfig.spec.json (289 bytes)
    CREATE apps/polpo-classroom-web/src/test-setup.ts (30 bytes)
    UPDATE angular.json (4087 bytes)
ng test polpo-classroom-web
    ● Validation Error:
        Preset ../../../jest.config.js not found.
        Configuration Documentation:
        https://jestjs.io/docs/configuration.html
    ● Validation Error:
        Preset ../../../jest.config.js not found.
        Configuration Documentation:
        https://jestjs.io/docs/configuration.html

When I change ../../.. to ../.. in the jest.config.jsand tsconfig.spec.json from the specific app folder, it works

ernie58 commented 6 years ago

this is my angular.json file:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "",
  "projects": {
    "polpo-classroom-web": {
      "root": "apps/polpo-classroom-web/",
      "sourceRoot": "apps/polpo-classroom-web/src",
      "projectType": "application",
      "prefix": "campus",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/apps/polpo-classroom-web",
            "index": "apps/polpo-classroom-web/src/index.html",
            "main": "apps/polpo-classroom-web/src/main.ts",
            "polyfills": "apps/polpo-classroom-web/src/polyfills.ts",
            "tsConfig": "apps/polpo-classroom-web/tsconfig.app.json",
            "assets": [
              "apps/polpo-classroom-web/src/favicon.ico",
              "apps/polpo-classroom-web/src/assets"
            ],
            "styles": [
              "apps/polpo-classroom-web/src/styles.css"
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "apps/polpo-classroom-web/src/environments/environment.ts",
                  "with": "apps/polpo-classroom-web/src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "polpo-classroom-web:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "polpo-classroom-web:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "polpo-classroom-web:build"
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "apps/polpo-classroom-web/tsconfig.app.json",
              "apps/polpo-classroom-web/tsconfig.spec.json",
              "apps/polpo-classroom-web/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        },
        "test": {
          "builder": "@nrwl/builders:jest",
          "options": {
            "jestConfig": "apps/polpo-classroom-web/jest.config.js",
            "tsConfig": "apps/polpo-classroom-web/tsconfig.spec.json",
            "setupFile": "apps/polpo-classroom-web/src/test-setup.ts"
          }
        }
      }
    },
    "polpo-classroom-web-e2e": {
      "root": "apps/polpo-classroom-web-e2e/",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "apps/polpo-classroom-web-e2e/protractor.conf.js",
            "devServerTarget": "polpo-classroom-web:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "polpo-classroom-web:serve:production"
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "apps/polpo-classroom-web-e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "cli": {
    "warnings": {
      "typescriptMismatch": false,
      "versionMismatch": false
    },
    "defaultCollection": "@nrwl/schematics"
  },
  "defaultProject": "polpo-classroom-web"
}
github-actions[bot] commented 1 year ago

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.