0

I am using Angular 8 in my project. Is it possible to have a separate package.json file for e2e tests? I am using jest for unit testing and protractor+jasmine for e2e. Because of this, I can't completely remove jasmine from my package.json. And, therefore, I often have problems with typings

What I want to get:

  1. when i am in the .spec file that is inside main project expect(someFuncCall()).toMatchSnapshot() should works correct and jasmine should not work

  2. when i am in the .spec file that is inside e2e folder toMatchSnapshot() should give an error and jest should not work

Of course, all IDE intellisense for tests should differ depends on project type: e2e/main

skyboyer
  • 22,209
  • 7
  • 57
  • 64
mr__brainwash
  • 1,334
  • 3
  • 16
  • 40

1 Answers1

2

Stumbled on this old question when looking for the same thing.

In our project, we use jest for normal component testing and protractor + jasmine for e2e tests. This is done with a separate package.json for the e2e tests.

  • In the /e2e folder, manually add a package.json file with your desired dependencies.
  • in there you can run npm i as usual (creates a node_modules folder and package-lock.json in there)
  • the tsconfig.e2e.json file we use for this looks as follows:
{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "",
    "outDir": "../out-tsc/e2e",
    "module": "commonjs",
    "target": "es5",
    "types": [
      "jasmine",
      "node"
    ],
    "allowJs": true,
    "importHelpers": true,
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "typeRoots": [
      "node_modules/@types",
      "../node_modules/@types"
    ],
    "lib": [
      "es2016",
      "dom"
    ],
  },
  "exclude": [
    ...
  ]
}

I didn't want to clutter this post with too much stuff. If anything is missing, I'll be happy to post other infos (package.json, protractor.conf, etc.).

MikeJ82
  • 153
  • 1
  • 12
  • 1
    I would be grateful if you add all related informations, mainly the package.json (I'm looking for a similar solution with Cypress ) – Smaillns Jun 08 '21 at 11:25