HalitTalha / ng-material-extensions

Extended features for @angular/material components
Apache License 2.0
101 stars 52 forks source link

ng test with karma won't work. #122

Closed csanctis closed 3 years ago

csanctis commented 3 years ago

Chrome Headless 91.0.4472.124 (Windows 10) DetailTableComponent should create FAILED Error: NG0301: Export of name 'matTableExporter' not found!. Find more at https://angular.io/errors/NG0301 error properties: Object({ code: '301' }) Error: NG0301: Export of name 'matTableExporter' not found!. Find more at https://angular.io/errors/NG0301 at cacheMatchingLocalNames (node_modules/@angular/core/ivy_ngcc__/fesm2015/core.js:10358:1) at resolveDirectives (node_modules/@angular/core/ivy_ngcc/fesm2015/core.js:10189:1) at elementStartFirstCreatePass (node_modules/@angular/core/__ivy_ngcc/fesm2015/core.js:14793:1) at ɵɵelementStart (node_modules/@angular/core/ivy_ngcc/fesm2015/core.js:14830:1) at DetailTableComponent_Template (ng:///DetailTableComponent.js:187:9) at executeTemplate (node_modules/@angular/core/ivy_ngcc/fesm2015/core.js:9579:1) at renderView (node_modules/@angular/core/ivy_ngcc__/fesm2015/core.js:9383:1) at renderComponent (node_modules/@angular/core/ivy_ngcc/fesm2015/core.js:10663:1) at renderChildComponents (node_modules/@angular/core/__ivy_ngcc/fesm2015/core.js:9248:1) at renderView (node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:9408:1) Error: Expected undefined to be truthy. at at UserContext. (src/app/@shared/detail-table/detail-table.component.spec.ts:29:23) at ZoneDelegate.invoke (node_modules/zone.js/fesm2015/zone.js:372:1) at ProxyZoneSpec.onInvoke (node_modules/zone.js/fesm2015/zone-testing.js:287:1) Chrome Headless 91.0.4472.124 (Windows 10): Executed 108 of 109 (1 FAILED) (skipped 1) (0.886 secs / 0.686 secs)

package.json:

{ "name": "cbmss-frontend", "version": "1.0.12", "private": true, "scripts": { "ng": "ng", "build": "npm run write:env -s && ng build --configuration=production", "build:dev": "npm run write:env -s && ng build --configuration=development", "build:prod": "npm run write:env -s && ng build --configuration=production", "build-storybook": "build-storybook -- -o ./dist/storybook", "local": "npm run write:env -s && ng serve --proxy-config proxy.local.conf.js", "prod": "npm run write:env -s && ng serve --proxy-config proxy.prod.conf.js", "dev": "npm run write:env -s && ng serve --proxy-config proxy.dev.conf.js", "deploy": "npm run write:env -s && ng deploy", "lint": "ng lint && stylelint \"src//*.scss\" --syntax scss && htmlhint \"src\" --config .htmlhintrc", "test": "npm run write:env -s && ng test", "test:ci": "npm run write:env -s && npm run lint -s && ng test --configuration=ci", "e2e": "npm run write:env -s && ng e2e", "translations:extract": "ngx-translate-extract --input ./src --output ./src/translations/template.json --format=json --clean --sort", "docs": "hads ./docs -o", "write:env": "ngx-scripts env npm_package_version", "prettier": "prettier --write \"./{src,e2e}/*/.{ts,js,html,scss}\"", "prettier:check": "prettier --list-different \"./{src,e2e}//.{ts,js,html,scss}\"", "postinstall": "npm run prettier -s", "generate": "ng generate", "docs:json": "compodoc -p ./tsconfig.json -e json -d .", "storybook": "npm run docs:json && start-storybook -p 6006" }, "dependencies": { "@angular/animations": "12.1.0", "@angular/cdk": "12.1.0", "@angular/common": "12.1.0", "@angular/compiler": "12.1.0", "@angular/core": "12.1.0", "@angular/flex-layout": "12.0.0-beta.34", "@angular/forms": "12.1.0", "@angular/localize": "12.1.0", "@angular/material": "12.1.0", "@angular/platform-browser": "12.1.0", "@angular/platform-browser-dynamic": "12.1.0", "@angular/router": "12.1.0", "@auth0/angular-jwt": "5.0.2", "@azure/ng-deploy": "0.2.3", "@ngrx/effects": "12.1.0", "@ngrx/store": "12.1.0", "@ngrx/store-devtools": "12.1.0", "@ngx-translate/core": "13.0.0", "angulartics2": "10.0.0", "lodash": "4.17.21", "mat-table-exporter": "^10.2.3", "material-design-icons-iconfont": "6.1.0", "please-upgrade-node": "^3.2.0", "postcss": "8.3.5", "rxjs": "6.6.7", "tslib": "2.3.0", "zone.js": "0.11.4" }, "devDependencies": { "@angular-devkit/build-angular": "12.1.0", "@angular-eslint/builder": "12.1.0", "@angular-eslint/eslint-plugin": "12.1.0", "@angular-eslint/eslint-plugin-template": "12.1.0", "@angular-eslint/schematics": "12.1.0", "@angular-eslint/template-parser": "12.1.0", "@angular/cli": "12.1.0", "@angular/compiler-cli": "12.1.0", "@angular/language-service": "12.1.0", "@babel/core": "7.14.6", "@biesbjerg/ngx-translate-extract": "7.0.4", "@biesbjerg/ngx-translate-extract-marker": "1.0.0", "@compodoc/compodoc": "1.1.11", "@ngneat/until-destroy": "8.0.4", "@ngx-rocket/scripts": "5.1.0", "@storybook/addon-actions": "6.3.0", "@storybook/addon-essentials": "6.3.0", "@storybook/addon-links": "6.3.0", "@storybook/angular": "6.3.0", "@types/jasmine": "3.7.7", "@types/jasminewd2": "2.0.9", "@types/lodash": "4.14.170", "@types/node": "14.14.31", "@typescript-eslint/eslint-plugin": "4.28.0", "@typescript-eslint/parser": "4.28.0", "angular-auth-oidc-client": "11.6.11", "babel-loader": "8.2.2", "codelyzer": "6.0.2", "eslint": "7.29.0", "hads": "3.0.0", "htmlhint": "0.15.1", "https-proxy-agent": "5.0.0", "husky": "6.0.0", "is-docker": "2.2.1", "jasmine-core": "3.7.1", "jasmine-spec-reporter": "7.0.0", "karma": "6.3.4", "karma-chrome-launcher": "3.1.0", "karma-coverage": "2.0.3", "karma-jasmine": "4.0.1", "karma-jasmine-html-reporter": "1.6.0", "karma-junit-reporter": "2.0.1", "prettier": "2.3.2", "pretty-quick": "3.1.1", "protractor": "7.0.0", "stylelint": "13.13.1", "stylelint-config-prettier": "8.0.2", "stylelint-config-recommended-scss": "4.2.0", "stylelint-config-standard": "22.0.0", "stylelint-scss": "3.19.0", "ts-node": "10.0.0", "tslint": "6.1.3", "tslint-config-prettier": "1.18.0", "typescript": "4.3.4" }, "prettier": { "singleQuote": true, "overrides": [ { "files": ".scss", "options": { "singleQuote": false } } ] }, "husky": { "hooks": { "pre-commit": "pretty-quick --staged" } } }

csanctis commented 3 years ago

Code works fine when running the app, but I can't get the test to recognize the directive.

csanctis commented 3 years ago

Turns out I had to declare the MatTableExporterModule at the beginning of the class setup. Closing the issue.