SyntaxError: Неожиданный экспорт токенов с помощью решения SPFx при запуске Jest - PullRequest
0 голосов
/ 09 марта 2020

Я получаю эту ошибку:

 FAIL  src\webparts\crud\__test__\CrudWebPart.test.tsx
  ● Test suite failed to run

    C:\Users\admin\Desktop\github\crud-simple-test\node_modules\@microsoft\sp-http\lib\index.js:12
    export { default as HttpClient } from './httpClient/HttpClient';
    ^^^^^^

    SyntaxError: Unexpected token export

      54 | 
      55 |     async postTodo() {
    > 56 |         const value = await this.addItem(this.state.todo);
      57 |         const action = postTodoCreator(value);
      58 |         store.dispatch(action)
      59 |     }

      at ScriptTransformer._transformAndBuildScript (node_modules/jest/node_modules/jest-runtime/build/script_transformer.js:316:17)
      at Object.<anonymous> (src/webparts/crud/components/Todolist/Todolist.tsx:56:68)
      at Object.<anonymous> (src/webparts/crud/components/Crud.tsx:17:70)

  console.log src\webparts\crud\components\Store\reducers.ts:27
    action type @@redux/INITb.1.9.m.y.8 is not found

Handlebars: Access has been denied to resolve the property "statements" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "branches" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "functions" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "lines" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |  Unknown |  Unknown |  Unknown |  Unknown |                   |
----------|----------|----------|----------|----------|-------------------|
Jest: Coverage data for global was not found.
Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        8.522s
Ran all test suites.
testResultsProcessor support is deprecated. Please use jest reporter. See https://github.com/jest-community/jest-junit#usage:

{
  "reporters": [
    "jest-junit"
  ]
}

npm ERR! Test failed.  See above for more details.

Это странно, потому что после некоторого исследования я изменил свою конфигурацию:

"transformIgnorePatterns": [
  "/node_modules/(?!@microsoft/sp-core-library|sp-dialog|sp-http)"
],

И все же это небольшое исправление не похоже на сократить это, хотя это, кажется, то, что люди сделали, чтобы исправить подобные проблемы. Это проблема Typescript или это что-то еще? И как мне убедиться, что компилятор Typescript выполняет свою работу?

...