npm run e2e and getting this error
- I'm submitting a ...
[x ] bug report
I just got fresh copy and trying to npm run e2e and getting this error - i know it was reported perviously but it seems it has regressed
[11:42:33] E/launcher - Error: TSError: ⨯ Unable to compile TypeScript
i know this has previously been addressed with adding this to tsconfig.json "files": [ "src/main.ts", "typings/browser.d.ts", "node_modules/zone.js/dist/zone.js.d.ts" ]
but having no luck with it! Does anybody have a solution?
Make sure you get the latest commits for tsconfig:
I'm encountering the same error myself, even with the latest commits. The initial errors for me are with definition files underneath node_modules/angular/{common,compiler}/esm/src.
Crash-coursing my definition-file knowledge so I hopefully can be more useful than this.
Same issue here... fresh clone. Fresh install of typings as global (basically following the readme) and afterwards a npm install.
Extract of error messages
E/launcher - Error: TSError: ⨯ Unable to compile TypeScript
node_modules/@angular/common/esm/src/directives/ng_for.d.ts (7,5): Duplicate identifier 'readonly'. (2300)
node_modules/@angular/common/esm/src/directives/ng_for.d.ts (7,14): '=' expected. (1005)
node_modules/@angular/common/esm/src/directives/ng_for.d.ts (7,14): Cannot find name 'first'. (2304)
node_modules/@angular/common/esm/src/directives/ng_for.d.ts (7,19): ';' expected. (1005)
There are a lot more.
Typings version installed globally 1.0.4... only way to make the e2e tests working again was to reset the changes in the repo when using 0.8.1 and then a npm run clean:install
Any help would be appreciated.
Like TobiasKrogh, I get a mile of "Duplicate identifier" messages. But mine come from the node typings and result in an error: typings/globals/node/index.d.ts (2147,18): Class 'Domain' incorrectly implements interface 'NodeJS.Domain'. Types of property 'addListener' are incompatible. Type '(event: string, listener: Function) => EventEmitter' is not assignable to type '{ (event: string, listener: Function): this; (event: string, listener: Function): this; (event: s...'. Type 'EventEmitter' is not assignable to type 'this'. (2420) at getOutput (/Volumes/Fantomas/angular2-webpack/node_modules/ts-node/src/ts-node.ts:210:13) at Object.loader (/Volumes/Fantomas/angular2-webpack/node_modules/ts-node/src/ts-node.ts:225:23) at Module.load (module.js:356:32) at Function.Module._load (module.js:311:12) at Module.require (module.js:366:17) at require (module.js:385:17) at /Volumes/Fantomas/angular2-webpack/node_modules/protractor/node_modules/jasmine/lib/jasmine.js:56:5 at Array.forEach (native) at Jasmine.loadSpecs (/Volumes/Fantomas/angular2-webpack/node_modules/protractor/node_modules/jasmine/lib/jasmine.js:55:18) at Jasmine.execute (/Volumes/Fantomas/angular2-webpack/node_modules/protractor/node_modules/jasmine/lib/jasmine.js:111:8) [launcher] Process exited with error code 100
I got this to work.
Replace:
filesGlob: [...] and exclude: [...]
with
"files": [ "src/main.ts", "typings/browser.d.ts", "node_modules/zone.js/dist/zone.js.d.ts", "./src/custom-typings.d.ts", "./typings/index.d.ts" ],
(Typescript will throw an error if you have filesGlob or exclude with files).
Also make sure your dev server is running as well in a seperate process. Protractor isn't going to start your server for you, it's only going to access the localhost:3000 port.
See: 4f35422
I was able to get this working by renaming filesGlob to files and commenting out exclude, as pointed out above.
In order to get tests passing the app had to be running by first using npm run start. After that you can do npm run e2e and all tests pass.
I needed to fully automate this for CI by calling a single npm script. Updating my npm e2e script to this solved it:
"e2e": "(webdriver-manager start &) && sleep 2 && (npm run start . &) && npm run protractor"
The only remaining issue is how to shut down selenium and webpack-dev-server after tests run. I am getting "address already in use" for both when running the tests more than once. They still end up running but it looks ugly in the console. This is not a big deal for CI since the container will be destroyed with each build. But for local development it could be a lot cleaner without the noise. Any ideas?
Above solution seems to work, but main.ts has moved to main.component.ts and typings/browser.d.ts needs to be removed from the list as it seems to no longer be included.
So it looks like this now:
"files": [ "src/main.component.ts", "node_modules/zone.js/dist/zone.js.d.ts", "./src/custom-typings.d.ts", "./typings/index.d.ts" ],
Another thing to note is that the Aurelia Skeleton app has a working "gulp e2e" script. It stands up the server, runs the tests, and dismisses without errors.
It may be worth looking at how it is done in order to make this work well with CI systems.
Are there some workarounds for
"exclude": [
"./node_modules",
"./typings/main.d.ts",
"./typings/main"
],
"filesGlob": [
"./src/app/**/*.ts",
"./src/platform/**/*.ts",
"!./node_modules/**",
"./src/custom-typings.d.ts",
"./typings/index.d.ts"
],
in tsconfig?
@Andrey-Pavlov There is solution thumbed up 19 days ago with diff... worked for me, essentially I had to do this
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"noEmitHelpers": true
},
"files": [
"src/main.ts",
"node_modules/zone.js/dist/zone.js.d.ts",
"./src/custom-typings.d.ts",
"./typings/index.d.ts"
],
// "exclude": [
// "./node_modules",
// "./typings/main.d.ts",
// "./typings/main"
// ],
// "filesGlob": [
// "./src/app/**/*.ts",
// "./src/platform/**/*.ts",
// "!./node_modules/**",
// "./src/custom-typings.d.ts",
// "./typings/index.d.ts"
// ],
"awesomeTypescriptLoaderOptions": {
"resolveGlobs": true,
"forkChecker": true
},
"compileOnSave": false,
"buildOnSave": false,
"atom": { "rewriteTsconfig": false }
}
Looks like typscript compiler doesn't seem to mind json having comments in it :)