question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

src/test.ts not found

See original GitHub issue

jest@24.5.0 jest-extended@0.11.1 jest-preset-angular@7.0.1 @angular/*@7.2.11 @angular/cli@7.3.7

 FAIL  src/app/file.spec.ts
  ● Test suite failed to run

    TypeScript diagnostics (customize using `[jest-config].globals.ts-jest.diagnostics` option):
    error TS6053: File 'C:/Users/.../projectHome/src/test.ts' not found.

I just upgraded from jest-preset-angular 6 to 7 and I get this error. Downgrading to version 6.0.2 works.

This are my config files:

// jest.config.js
module.exports = {
  preset: 'jest-preset-angular',
  roots: ['src'],
  setupFilesAfterEnv: ["./src/setup-jest.ts"],
  transformIgnorePatterns: [
    "node_modules/(?!@ngrx|angular2-ui-switch|ng-dynamic)"
  ],
  testPathIgnorePatterns: [
    '/node_modules/',
    '/src/environments/'
  ],
  moduleDirectories: [
    ".",
    "src",
    "src/util",
    "node_modules"
  ],
  moduleNameMapper: {
    '@config/(.*)': 'src/app/config/$1',
    '@dashboard/(.*)': 'src/app/dashboard/$1',
    '@documents/(.*)': 'src/app/documents/$1',
    "@kyc/(.*)": "src/app/kyc/$1",
    '@logging/(.*)': 'src/app/logging/$1',
    '@mapping/(.*)': 'src/app/mapping/$1',
    '@reviews/(.*)': 'src/app/review/$1',
    '@root/(.*)': 'src/app/root/$1',
    '@shared/(.*)': 'src/app/shared/$1',
    '@signalr/(.*)': 'src/app/signalr/$1',
    '@store': 'src/app/store',
    '@store/(.*)': 'src/app/store/$1',
    '@users/(.*)': 'src/app/users/$1',
    '@util': 'src/app/util',
    '@util/(.*)': 'src/app/util/$1',
    "@verifications/(.*)": "src/app/verifications/$1",
  }
};
// src/setup-jest.js
import 'jest-preset-angular';
import './jestGlobalMocks';

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
gaglecommented, Mar 29, 2019
// ts.config.spec
{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/spec",
    "module": "commonjs",
    "types": [
      "jest",
      "node"
    ]
  },
  "files": [
    "test.ts",
    "polyfills.ts"
  ],
  "include": [
    "**/*.spec.ts",
    "**/*.d.ts"
  ]
}

I removed the src/test.ts along with the angular.json “test” script karma builder as I don’t need them. I just test with the command “jest”.

1reaction
gaglecommented, Mar 29, 2019

Oh, I’m sorry, I didn’t look at tsconfig.spec. I jsut removed test.ts from files array. Sorry.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Angular testing - test.ts not found - Stack Overflow
I've done an npm install and when I run ng serve it builds fine. When I run ng test using the CLI, I...
Read more >
How I do configure Jest to test my Angular 8 Project - ITNEXT
By Angular CLI defaults you'll have a src/test.ts file which will be picked up by jest. To circumvent this you can ... It...
Read more >
ts-node - npm
ts ) and TypeScript resolves dependencies based on imports and references. Occasionally, this optimization leads to missing types. Fortunately, ...
Read more >
Configuring Jest
To read TypeScript configuration files Jest requires ts-node . ... no tests exist for this file and it's never required in the test...
Read more >
Component testing scenarios - Angular
You update the beforeEach to find that element with a standard HTML querySelector and ... If you use the Angular CLI, configure this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found