microsoft / windows-admin-center-sdk

SDK including documentation and sample code for developing extensions for Windows Admin Center (previously Project Honolulu)
Other
119 stars 51 forks source link

run jest case fail with wac sdk 2.166.0 #220

Open Shanxian opened 3 years ago

Shanxian commented 3 years ago

hi author, An error occurred during running case by jest

● Test suite failed to run
    Cannot find module './backdrop.component.html' from 'microsoft-windows-admin-center-sdk-angular.umd.js'
      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:221:17)
      at node_modules/@microsoft/windows-admin-center-sdk/angular/bundles/microsoft-windows-admin-center-sdk-angular.umd.js:710:2039
      at node_modules/@microsoft/windows-admin-center-sdk/angular/bundles/microsoft-windows-admin-center-sdk-angular.umd.js:710:2332
      at node_modules/@microsoft/windows-admin-center-sdk/angular/bundles/microsoft-windows-admin-center-sdk-angular.umd.js:1:109
      at Object.<anonymous> (node_modules/@microsoft/windows-admin-center-sdk/angular/bundles/microsoft-windows-admin-center-sdk-angular.umd.js:1:12840)

package.json

"dependencies": {
        "@angular/animations": "11.2.14",
        "@angular/common": "11.2.14",
        "@angular/core": "11.2.14",
        "@angular/forms": "11.2.14",
        "@angular/platform-browser": "11.2.14",
        "@angular/platform-browser-dynamic": "11.2.14",
        "@angular/router": "11.2.14",
        "@microsoft/windows-admin-center-sdk": "2.166.0",
        "@ngrx/effects": "^11.0.0",
        "@ngrx/router-store": "^11.0.0",
        "@ngrx/store": "^11.0.0",
        "core-js": "2.6.0",
        "rxjs": "6.6.0",
        "zone.js": "0.11.3"
    },
    "devDependencies": {
        "@angular-devkit/build-angular": "0.1102.13",
        "@angular-devkit/build-ng-packagr": "0.1002.0",
        "@angular-devkit/build-optimizer": "0.1102.13",
        "@angular/animations": "11.2.14",
        "@angular/cli": "11.2.14",
        "@angular/common": "11.2.14",
        "@angular/compiler": "11.2.14",
        "@angular/compiler-cli": "11.2.14",
        "@angular/core": "11.2.14",
        "@angular/forms": "11.2.14",
        "@angular/language-service": "11.2.14",
        "@angular/platform-browser": "11.2.14",
        "@angular/platform-browser-dynamic": "11.2.14",
        "@angular/router": "11.2.14",
        "@microsoft/windows-admin-center-sdk": "2.166.0",
        "@ngrx/store-devtools": "^11.0.0",
        "@types/chart.js": "2.9.32",
        "@types/jest": "^22.1.3",
        "@types/node": "^12.11.1",
        "ajv": "6.4.0",
        "ansi-colors": "1.0.1",
        "body-parser": "^1.18.2",
        "chart.js": "2.9.4",
        "codelyzer": "^6.0.0",
        "core-js": "2.6.0",
        "express": "^4.16.2",
        "gulp": "4.0.0",
        "gulp-clean": "0.4.0",
        "gulp-inline-ng2-template": "5.0.1",
        "gulp-jasmine": "4.0.0",
        "gulp-plumber": "1.1.0",
        "gulp-rename": "1.2.2",
        "gulp-sourcemaps": "2.6.4",
        "gulp-tslint": "8.1.3",
        "gulp-watch": "4.3.11",
        "jasmine-reporters": "2.4.0",
        "jest": "^23.6.0",
        "jest-preset-angular": "^6.0.2",
        "jquery": "3.6.0",
        "jsdom": "9.10.0",
        "ng-mocks": "11.10.1",
        "ng-packagr": "11.2.4",
        "plugin-error": "1.0.1",
        "protractor": "~7.0.0",
        "readline-sync": "1.4.9",
        "run-sequence": "2.2.0",
        "rxjs": "6.6.0",
        "rxjs-tslint": "0.1.8",
        "rxjs-tslint-rules": "4.10.0",
        "selenium-webdriver": "3.6.0",
        "ts-helpers": "^1.1.1",
        "ts-jest": "^23.1.4",
        "ts-node": "~8.3.0",
        "tsickle": "0.37.0",
        "tslint": "~6.1.0",
        "tslint-consistent-codestyle": "1.14.0",
        "tslint-eslint-rules": "5.4.0",
        "tslint-microsoft-contrib": "5.2.1",
        "typescript": "4.1.5",
        "zone.js": "0.11.3"
    },
        "jest": {
        "testURL": "http://localhost",
        "preset": "jest-preset-angular",
        "moduleNameMapper": {
            "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
            "\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js"
        },
        "setupTestFrameworkScriptFile": "<rootDir>/src/setupJest.ts",
        "testMatch": [
            "**/src/**/*.spec.ts"
        ],
        "globals": {
            "ts-jest": {
                "tsConfigFile": "<rootDir>/src/tsconfig.spec.json"
            },
            "__TRANSFORM_HTML__": true
        },
        "coveragePathIgnorePatterns": [
            "node_modules/"
        ],
        "transformIgnorePatterns": [
            "node_modules/(?!@ngrx|@microsoft)"
        ]
    }

tsconfig.spec.json

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "allowJs": true,
    "module": "commonJs",
    "outDir": "spec",
    "types": ["jest", "node"]
  },
  "files": ["polyfills.ts"],
  "include": ["**/*.spec.ts", "**/*.d.ts", "../__mocks__/*.ts"]
}

How to solve such an error