I'm having an issue running "ng test" in my angular project. When I run I get the following output:
ERROR in ./node_modules/selenium-webdriver/lib/http.js Module not found: Error: Can't resolve 'fs' in 'C:\Users\test\Desktop\ui-portal\node_modules\selenium-webdriver\lib' @ ./node_modules/selenium-webdriver/lib/http.js 28:11-24 @ ./node_modules/selenium-webdriver/http/index.js @ ./src/app/container/container.component.spec.ts @ ./src .spec.ts$ @ ./src/test.ts
-
ERROR in ./node_modules/selenium-webdriver/lib/devmode.js Module not found: Error: Can't resolve 'fs' in 'C:\Users\test\Desktop\ui-portal\node_modules\selenium-webdriver\lib' @ ./node_modules/selenium-webdriver/lib/devmode.js 25:11-24 @ ./node_modules/selenium-webdriver/lib/http.js @ ./node_modules/selenium-webdriver/http/index.js @ ./src/app/container/container.component.spec.ts @ ./src .spec.ts$ @ ./src/test.ts
I've been searching for an answer but can't find anything that's helping - has anyone seen this particular issue before? My package.json file is as follows:
{
"name": "ui-portal",
"version": "0.0.1",
"license": "MIT",
"scripts": {
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"@ngx-translate/core": "9.1.1",
"@ngx-translate/http-loader": "2.0.1",
"applicationinsights-js": "^1.0.18",
"bootstrap": "3.3.7",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"ng4-loading-spinner": "^1.1.3",
"ngx-bootstrap": "^3.0.1",
"rxjs": "^5.5.6",
"source-sans-pro": "^2.20.2",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular/cli": "1.6.5",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@compodoc/compodoc": "^1.0.1",
"@types/chai": "^3.5.1",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"diff": "^3.4.0",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-mocha-reporter": "^2.2.3",
"karma-sourcemap-loader": "^0.3.7",
"karma-tfs-reporter": "^1.0.1",
"mocha": "^4.0.1",
"onchange": "^3.2.1",
"protractor": "~5.1.2",
"rimraf": "^2.6.1",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3",
"webpack-bundle-analyzer": "^2.9.0"
}
}
Thanks in advance for any pointers guys! Really not making progress with this one :(
I had the same issue with ng test on
Angular CLI: 6.1.2 Node: 8.9.1
The problem for me was using the
wrong
HttpClient
. import in my test file.
Make sure your HttpClient is from '@angular/common/http';
and not imported from Selenium
.
Hope this helps :)
I had the same issue, because it imported EventEmitter
from 'protractor'
instead of angular-core
For some reasons my IntelliJ added:
import { beforeEach } from 'selenium-webdriver/testing';
which was causing the issue. Removing it solved the problem for me.
Remove the import 'jasmine'
from the ts file.
If the editor is complaining about missing types jasmine
"compilerOptions": {
"types": [
"jasmine",
...
]
}
More reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With