1
  1. I have some common TS library that uses @uifabric/foundation npm package. This library exposes some React components, that are based on uifabric code style and patterns.
  2. There is also a TS/React/Redux project that consumes this library (using npm link). Compiles and works without problems.
  3. The project comtains some test scenarios. Used stack: mocha, enzyme, sinon, chai. Compiles without problems, but when executing mocha tests I constantly get
[sharedlibpath]\node_modules\@uifabric\utilities\lib\index.js:1
(function (exports, require, module, __filename, __dirname) { export * from './Async';
                                                              ^^^^^^

SyntaxError: Unexpected token export

Checked the output js file from component that is failing and it's the line var lib_1 = require("@uifabric/utilities/lib");

Can anybody shed some light on how to solve this problem?

1 Answers1

0

Update: Seems problem with module resolution. Dofferent for compilation and different for test run. Solution for jest is described in MS Fabric Wiki: https://github.com/OfficeDev/office-ui-fabric-react/wiki/Fabric-6-Release-Notes

But then when my components import not from @uifabric/utilities/lib but @uifabric/utilities/lib-commonjs this leads to: "Cannot find module" when running unit tests on node.js with react as peer dependency in common package