I started getting this error today in the test suite of an Angular.js 1.5/Angular 5 project:
HeadlessChrome 64.0.3282 (Linux 0.0.0) ERROR
An error was thrown in afterAll
Uncaught ReferenceError: require is not defined
The issue appears after all of my tests have run successfully. What is bizarre is it runs well locally, but it's in a Jenkins CI server where it fails. From the other developers only 1 in 10 is seeing the same problem as Jenkins.
There are tons of other posts mentioning this same error but none addressed my exact problem, like this, this, this, ...
Anybody knows what the issue can be?
Edit:
The exception happens in modernizr/lib/cli.js
, but no stack-trace appears:
and we get no call stack either:
After looking at the bower dependencies of our project with bower ls -o
, we found a difference in a transient dependency of Zurb Foundation.
In the places were it worked, modernizr
was set to 3.5.0
:
├─┬ foundation#5.5.1
│ ├── fastclick#1.0.6
│ ├── jquery#2.1.4
│ ├─┬ jquery-placeholder#2.0.9
│ │ └── jquery#2.1.4
│ ├─┬ jquery.cookie#1.4.1
│ │ └── jquery#2.1.4
│ └── modernizr#3.5.0
In the places were it didn't work, it was set to 3.9.0
:
├─┬ foundation#5.5.1
│ ├── fastclick#1.0.6
│ ├── jquery#2.1.4
│ ├─┬ jquery-placeholder#2.0.9
│ │ └── jquery#2.1.4
│ ├─┬ jquery.cookie#1.4.1
│ │ └── jquery#2.1.4
│ └── modernizr#3.9.0
Forcing the modernizr
version to 3.5.0
in bower.json
solved the issue:
"dependencies": {
...
"modernizr": "3.5.0"
}
I don't fully understand why modernizr was resolved to different versions in some computers, as in both cases we had the same Zurb Foundation's version pinned, but this was the way we fixed the issue.