项目作者: smukked

项目描述 :
SPFx Jest Demo
高级语言: TypeScript
项目地址: git://github.com/smukked/spfx-jest-demo.git
创建时间: 2019-05-13T10:22:33Z
项目社区:https://github.com/smukked/spfx-jest-demo

开源协议:

下载


SPFx React Jest Demo

SPFx 1.8.2 example running React and Jest.

Execute tests

  1. npm test
  2. npm run test:watch

Changes made to standard SPFx

  1. // package.json
  2. "devDependencies": {
  3. "@microsoft/rush-stack-compiler-3.3": "^0.2.15",
  4. "@voitanos/jest-preset-spfx-react16": "^1.2.0",
  5. "inline-css": "^2.4.2",
  6. "jest-trx-results-processor": "^0.1.0",
  7. "typescript": "3.3"
  8. ...
  9. }
  1. // tsconfig.json
  2. {
  3. "extends": "./node_modules/@microsoft/rush-stack-compiler-3.3/includes/tsconfig-web.json",
  4. "compilerOptions": {
  5. "esModuleInterop": true,
  6. }
  7. }

Optional

If you are working with Office UI Fabric, you might need this.

  1. // jest.config.json
  2. {
  3. "moduleNameMapper": {
  4. "office-ui-fabric-react/lib/(.*)$": "office-ui-fabric-react/lib-commonjs/$1"
  5. }
  6. }