Closed Dethlore closed 4 years ago
Hi @Dethlore,
Could you please share src/polyfills.ts
file content?
Of course!
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
* Learn more in https://angular.io/guide/browser-support
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/**
* Web Animations `@angular/platform-browser/animations`
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
*/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
* because those flags need to be set before `zone.js` being loaded, and webpack
* will put import in the top of bundle, so user need to create a separate file
* in this directory (for example: zone-flags.ts), and put the following flags
* into that file, and then add the following code before importing zone.js.
* import './zone-flags.ts';
*
* The flags allowed in zone-flags.ts are listed here.
*
* The following flags will work for all browsers.
*
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
* (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*
* (window as any).__Zone_enable_cross_context_check = true;
*
*/
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/
Looks good, could you please share your angular.json file?
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"mtk": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "ngx-build-plus:build",
"options": {
"baseHref": "/Content/",
"outputPath": "dist/mtk",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets",
{
"input": "node_modules/fullcalendar/dist",
"glob": "fullcalendar.css",
"output": "./assets/styles/fullcalendar.css"
},
{
"input": "node_modules/cesium/Build/Cesium",
"glob": "**/*",
"output": "./assets/cesium"
},
{
"input": "node_modules/font-awesome/fonts",
"glob": "**/*",
"output": "./assets/fonts"
},
{
"input": "dist/planner/assets",
"glob": "**/*",
"output": "./assets/planner/"
}
],
"styles": [
"node_modules/primeicons/primeicons.css",
"node_modules/primeng/resources/primeng.min.css",
"node_modules/@fullcalendar/core/main.min.css",
"node_modules/@fullcalendar/daygrid/main.min.css",
"node_modules/@fullcalendar/list/main.min.css",
"node_modules/@fullcalendar/timegrid/main.min.css",
"node_modules/font-awesome/css/font-awesome.min.css",
"node_modules/codemirror/lib/codemirror.css",
"node_modules/codemirror/theme/oceanic-next.css",
"src/styles.css",
"src/assets/styles/styles.css",
"src/assets/styles/dark.css",
"src/assets/styles/mtk.css",
"node_modules/cesium/Build/Cesium/Widgets/widgets.css"
],
"scripts": [
"node_modules/cesium/Build/Cesium/Cesium.js",
"node_modules/plotly.js/dist/plotly.min.js",
"node_modules/@fullcalendar/core/main.js",
"node_modules/@fullcalendar/list/main.js",
"node_modules/@fullcalendar/daygrid/main.js",
"node_modules/@fullcalendar/timegrid/main.js",
"node_modules/@fullcalendar/interaction/main.js"
]
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "20mb",
"maximumError": "40mb"
}
]
}
}
},
"serve": {
"builder": "ngx-build-plus:dev-server",
"options": {
"browserTarget": "mtk:build"
},
"configurations": {
"production": {
"browserTarget": "mtk:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "mtk:build"
}
},
"test": {
"builder": "ngx-build-plus:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": ["src/styles.css"],
"scripts": ["./node_modules/cesium/Build/Cesium/Cesium.js"],
"assets": ["src/favicon.ico", "src/assets"]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"],
"format": "checkstyle"
}
}
}
},
"mtk-e2e": {
"root": "e2e/",
"projectType": "application",
"prefix": "",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "mtk:serve"
},
"configurations": {
"production": {
"devServerTarget": "mtk:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": ["**/node_modules/**"],
"format": "checkstyle"
}
}
}
},
},
"defaultProject": "mtk"
}
Manual wallaby config file expects all projects to use default Angular CLI builder @angular-devkit/build-angular:karma
, however from your angular.json
file I see that you use third-party builder ngx-build-plus:karma
. To get wallaby working for your project it may be enough to simply replace @angular-devkit/build-angular:karma
with ngx-build-plus:karma
in your wallaby.js
config file, but if you use ngx-build-plus
to provide extra custom webpack configuration for your tests than you'll have to update your wallaby's webpack configuration accordingly.
That did it! Ahhh thank you so much!
@NikGovorov @Dethlore I am also using ngx-build-plus:karma
. Since I'm using Angular 11 I believe I have to use automatic configuration. How can I go about replacing @angular-devkit/build-angular:karma
with ngx-build-plus:karma
if I don't have a wallaby.js
file?
@tjrobinson - I have created #2693 to track your question/issue. We'll respond there.
On running ng test , I am getting this error :-
ReferenceError: Zone is not defined
at Object.
@aanchal88 Can you please create a separate new issue and provide the details requested in a new issue template? We are happy to take a look and help.
Sure!!!
Starting wallaby gives the error:
Wallaby Diagnostics Report: