tsconfig.json { “extends”: “./node_modules/pcf-scripts/tsconfig_base.json”, “compilerOptions”: { “typeRoots”: [“node_modules/@types”], “allowJs”: true, “skipLibCheck”: true, “esModuleInterop”: true, “allowSyntheticDefaultImports”: true, “forceConsistentCasingInFileNames”: true, “module”: “esnext”, “moduleResolution”: “node”, “resolveJsonModule”: true, “isolatedModules”: true, “sourceMap”: true }, “include”: [“./ConsumptionSummaryComponent/src”, “ConsumptionSummaryComponent/globals.d.ts”], “exclude”: [“./node_modules/pcf-scripts/./node_modules”] } .babelrc file { “env”: { “test”: { “plugins”: [ “@babel/plugin-transform-modules-commonjs” ] } } } Package.json { “name”: “pcf-project”, “version”: “1.0.0”, […]
- Tags '^.+\\.tsx?$': 'ts-jest' }, "^.*.svg$": "/src/blank-mock.js" }, "^.+\\.jsx$": "ts-jest" }, "^style-loader.*$": "/ConsumptionSummaryComponent/src/blank-mock", "@babel/preset-env": "^7.8.4", "@common-pcf/sdk": "file:../sdk/common-pcf-sdk-1.0.0.tgz", "@graphql-codegen/introspection": "1.12.1", "@graphql-codegen/typescript-operations": "1.12.1", "@graphql-codegen/typescript-react-apollo": "1.12.1", "@graphql-codegen/typescript": "1.12.1", "@microsoft/applicationinsights-web": "^2.3.1", "@types/enzyme-adapter-react-16": "1.0.6", "@types/enzyme": "3.10.5", "@types/jest": "^25.1.1", "@types/node": "^10.12.18", "@types/powerapps-component-framework": "^1.2.0", "@types/react-dom": "^16.9.5", "@types/react": "^16.9.19", "@uifabric/fluent-theme/lib/": "@uifabric/fluent-theme/lib-commonjs/", "@uifabric/icons": "^7.3.2", "@uifabric/styling/lib/": "@uifabric/styling/lib-commonjs/", "/ConsumptionSummaryComponent/src/services/**/*.{ts, "/js/**", "allowJs": true, "allowSyntheticDefaultImports": true, "apollo-boost": "^0.4.7", "babel-jest": "^25.1.0", "babelConfig": "/ConsumptionSummaryComponent/.babelrc", "clean": "pcf-scripts clean", "collectCoverage": true, "collectCoverageFrom": [ "/ConsumptionSummaryComponent/src/components/**/*.{ts, "compilerOptions": { "typeRoots": ["node_modules/@types"], "ConsumptionSummaryComponent/globals.d.ts"], "coverageDirectory": "test-coverage", "coverageReporters": ["lcov"], "coverageThreshold": { "global": { "branches": 0, "cra-template-typescript": "^1.0.0", "dependencies": { "@apollo/react-hooks": "^3.1.3", "description": "Project containing your PowerApps Component Framework (PCF) control.", "devDependencies": { "@babel/core": "7.8.4", "diagnostics": { "ignoreCodes": [ "TS1149" ] } } }, "enzyme-adapter-react-16": "^1.15.2", "enzyme-to-json": "3.4.4", "enzyme": "^3.11.0", "esModuleInterop": true, "exclude": ["./node_modules/pcf-scripts/./node_modules"] } .babelrc file { "env": { "test": { "plugins": [ "@ba, "expose-loader\\?jQuery\\!jquery": "/ConsumptionSummaryComponent/src/blank-mock", "forceConsistentCasingInFileNames": true, "functions": 0, "globals": { "ts-jest": { "tsConfig": "tsconfig.json", "graphql-tag": "^2.10.2", "graphql": "^14.6.0", "include": ["./ConsumptionSummaryComponent/src", "isolatedModules": true, "jest": "^25.1.0", "jest": { "roots": [ "/ConsumptionSummaryComponent/src" ], "lines": 0 } }, "module": "esnext", "moduleFileExtensions": [ "ts", "moduleNameMapper": { "ts-jest": "/node_modules/ts-jest", "moduleResolution": "node", "office-ui-fabric-react": "^7.84.0", "office-ui-fabric-react/lib/": "office-ui-fabric-react/lib-commonjs/", "pcf-scripts": "^1", "pcf-start": "^1", "react-dom": "^16.12.0", "react": "^16.12.0", "rebuild": "pcf-scripts rebuild", "resolveJsonModule": true, "scripts": { "build": "pcf-scripts build", "setupFiles": [ "/ConsumptionSummaryComponent/src/setupEnzyme.ts" ], "skipLibCheck": true, "source-map-loader": "^0.2.4", "sourceMap": true, "start": "pcf-scripts start", "statements": 0 } }, "test:watch": "jest --watch" }, "test": "jest", "transform": { "^.+\\.js$": "/node_modules/babel-jest", "ts-jest": "25.1.0", "ts-loader": "^6.2.1" } } SetupEnzyme.ts import { configure } from 'enzyme'; import Adapter from 'enzyme-adapter-react-16'; configure({, "version": "1.0.0", "webpack-cli": "^3.3.10", "webpack": "^4.41.5" } }, () => { const result = shallow(); expect(result).toMatchSnapshot(); }); Error Jest encountered an, e.g. it's not plain JavaScript. By default, iconName: Enums.ProductTypeLogo.azureLogo, iconStyle: styles.AzureIcon, if Jest sees a Babel config, ignoring "node_modules". Here's what you can do: • To have some of your "node_modules" files transformed, isEnabled:true, it will use that to transform your files, json, jsx, node, order: 1 }; it("Should render the Summary component for the test Product Group Summary", productGroupName: Enums.ProductTypeName.azureProductTypeName, snapshotSerializers: ['enzyme-to-json/serializer'], testEnvironment: 'node', testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$', ts=x, tsconfig.json { "extends": "./node_modules/pcf-scripts/tsconfig_base.json", you can specify a custom "transformIgnorePatterns" in your config. • If you need a custom transformation specify a "transform" option in you