sp-dev-fx-controls-react
sp-dev-fx-controls-react copied to clipboard
Cannot find module '@ms/odsp-core-bundle' or its corresponding type declarations while testing
Category
[ ] Enhancement
[ x] Bug
[ ] Question
Version
Please specify what version of the library you are using: [ 3.14.0 but same on 3.15.0 ]
Expected / Desired Behavior / Question
I am using FileTypeIcon component. It works as expected but error arises when performing tests using jest and react-testing-library.
I got error:
Cannot find module '@ms/odsp-core-bundle' from 'node_modules/@pnp/spfx-controls-react/node_modules/@microsoft/sp-core-library/lib-commonjs/SPExperiment.js'
and when opening SPExperiment.js file I got:
Observed Behavior
Test should go smoothly without errors.
Steps to Reproduce
Write test as below (sample)
import { FileTypeIcon, IconType, ImageSize } from "@pnp/spfx-controls-react";
import "@testing-library/jest-dom";
import { render } from "@testing-library/react";
import React from "react";
describe("<FileTypeIcon/>", () => {
it("renders file type icon", () => {
render(
<FileTypeIcon
type={IconType.image}
path={"some_url"}
size={ImageSize.small}
/>
);
//some assertions
});
});
Run test.
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
Thank you for submitting your first issue to this project.
Hi @Krugerro,
I'm not familiar with those testing libraries but I noticed the same issue if I try to bundle a SPFx solution which uses PnP Controls but without @microsoft/sp-core-library installed.
Is this package installed / loaded when you're running your tests?
Closing this as no response from the author. Feel free to reopen it if needed.