I have been working on integrating e2e tests into an Angular project that was not originally set up with @angular-cli, so I have been manually configuring most of it.
Currently, I am trying to define a script in the package.json file to transpile only the specs located in the tests/ folder to tests/compiled.
I attempted to follow the advice on this question: tsconfig.json - Only build ts files from folder. It suggests using --rootDir to specify the folder.
However, when I use this command: tsc --rootDir tests --outDir ./tests/compiled, it ends up compiling files from other directories like ./src. Additionally, I receive numerous TS6059 errors stating that rootDir should contain all source files.
For example: error TS6059: File 'C:/Users/Betalabs/Documents/Projetos/Engine-Frontend/src/vendor.browser.ts' is not under 'rootDir' 'tests'. 'rootDir' is expected to contain all source files.
The file structure is as follows. Note that the test specs (*.spec.ts) that I want to transpile are located in the tests/ folder.
(root)
-- src/
-- tests/
-- compiled/
-- (transpiled test files, ".js")
-- helpers/
-- (helper modules, ".ts")
-- page-objects/
-- (page objects, ".ts")
-- forms.spec.ts
-- filters.spec.ts
-- .gitignore
-- .tern-project
-- buildspec.yml
-- conf.js
-- package-lock.json
-- package.json
-- README.md
-- tsconfig.json
-- tsconfig.webpack.json
-- tslint.json
-- typedoc.json
-- webpack.config.js
This is my current tsconfig.json file:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"noEmitHelpers": true,
"importHelpers": true,
"strictNullChecks": false,
"baseUrl": "./src",
"paths": {
"@angular/*": ["node_modules/@angular/*"]
},
"lib": [
"dom",
"es6",
"es2017.object"
],
"typeRoots": [
"node_modules/@types"
],
"types": [
"jasmine",
"hammerjs",
"node",
"source-map",
"uglify-js",
"webpack"
]
},
"exclude": [
"node_modules",
"dist"
],
"awesomeTypescriptLoaderOptions": {
"forkChecker": true,
"useWebpackText": true
},
"compileOnSave": false,
"buildOnSave": false,
"atom": { "rewriteTsconfig": false }
}
Currently, my solution involves compiling all files and manually removing the unnecessary ones. It's quite messy! Could you offer any assistance with this issue?