1

I keep getting an error when running jasmine tests via karma test runner, which reads like this:

{
    "message": "An error was thrown in afterAll\nUncaught ReferenceError: container is not defined thrown",
    "str": "An error was thrown in afterAll\nUncaught ReferenceError: container is not defined thrown"
  }

My package.json is as follows:

 {
  "name": "3dm",
  "version": "1.0.0",
  "description": "3dm",
  "main": "src/index.html",
  "dependencies": {
    "three-obj-loader": "^1.1.3",
    "three.js": "*"
  },
  "devDependencies": {
    "jasmine-core": "^3.2.1",
    "karma-chrome-launcher": "*",
    "karma-cli": "*",
    "karma-jasmine": "^1.1.2",
    "istanbul": "^0.4.5",
    "jasmine": "^3.2.0",
    "karma": "^2.0.5",
    "karma-coverage": "^1.1.2",
    "karma-coverage-istanbul-reporter": "^2.0.3",
    "karma-htmlfile-reporter": "^0.3.6",
    "karma-istanbul-preprocessor": "*",
    "karma-jasmine-html-reporter": "^1.3.1",
    "karma-junit-reporter": "^1.2.0",
    "karma-rollup-preprocessor": "^5.1.1"
  },
  "author": "",
  "license": "ISC"
}

in my tests I don't even had anything like afterall or sth. Executing the tests via jasmine web interface everything works well. Just on CLI level I get this issue. Any ideas someone?

TomFree
  • 1,091
  • 3
  • 17
  • 31
  • It's likely that there is an afterAll block being added by angular or one of the libraries you are using. Can you include your package.json and list all the relevant libraries you are using? – Andrew Eisenberg Sep 02 '18 at 22:40
  • Sure here my package.json (see above) – TomFree Sep 03 '18 at 21:05
  • So, your project does not use angular? Also, npm should probably not be a depenedency of your project, and all karma and jasmine packages should be dev dependencies. – Andrew Eisenberg Sep 04 '18 at 01:00
  • No difference when removing npm and moving all jasmine or karma packages to dev only. Updated file above to latest version – TomFree Sep 04 '18 at 20:24

1 Answers1

1

Figured it out. It was because I had renamed a file that in karma.conf.js was loaded via wildcard and explicitly excluded whose filename I had changed from one lower case letter to an upper case letter. With adjustment of that name in the explicitly excluded file it works like a charm

TomFree
  • 1,091
  • 3
  • 17
  • 31