Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit testing typescript SPFx web part using jest #13

Open
rahil1998 opened this issue Nov 23, 2021 · 0 comments
Open

Unit testing typescript SPFx web part using jest #13

rahil1998 opened this issue Nov 23, 2021 · 0 comments

Comments

@rahil1998
Copy link

Question:

How do you unit test the SPFx web part, written in typescript (react), that uses @pnp Call to communicate with SharePoint?
How to mock PNP call or how to make ignorable for the test case.

below I mentions the error related to PNP

E:\Projects\Unit Testing\SPFx-unit-testing\node_modules\@pnp\logging\index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export * from "./logger";
                                                                                      ^^^^^^

    SyntaxError: Unexpected token export

      3 | import { IPnpSpCrudProps } from './IPnpSpCrudProps';
      4 | import { escape } from '@microsoft/sp-lodash-subset';
    > 5 | require("@pnp/logging");
        | ^
      6 | require("@pnp/common");
      7 | require("@pnp/odata");
      8 | import { sp } from "@pnp/sp/presets/all";

I have configured the unit test and sample test execute successfully (without PNP)
SPFx-unit-testing

Let me know your thoughts
@andrewconnell
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant