2

hello I have a problem with Unit tests in Single-Spa. Mine jest.config.js looks like this:

module.exports = {rootDir: "src",
  preset: "ts-jest",
  transform: {
    "^.+\\.(j|t)sx?$": "babel-jest",
    "^.+\\.(ts|tsx)?$": "ts-jest",
  },
  transformIgnorePatterns: [
    "/node_modules/(?![@autofiy/autofiyable|@autofiy/property]).+\\.js$",
    "/node_modules/(?![@autofiy/autofiyable|@autofiy/property]).+\\.ts$",
    "/node_modules/(?![@autofiy/autofiyable|@autofiy/property]).+\\.tsx$",
  ],
  moduleNameMapper: {
    "\\.(css)$": "identity-obj-proxy",
    "@App/root-config":
      "../../../../../AppMain/Frontend/ProAudioSuite.AppMain.Frontend/wwwroot/src/App-root-config",
    "single-spa":
      "../../../../../AppMain/Frontend/ProAudioSuite.AppMain.Frontend/wwwroot/libs/single-spa.js",
    System:
      "../../../../../AppMain/Frontend/ProAudioSuite.AppMain.Frontend/wwwroot/libs/system.js",
  },
  setupFilesAfterEnv: [
    "../node_modules/@testing-library/jest-dom/dist/index.js",
  ],
};

This is my root.component.test.js file

import React from "react";
import { render } from "@testing-library/react";
import Root from "./root.component";


describe("Root component", () => {
  it("should be in the document", () => {
    const { getByText } = render(<Root name="Testapp" />);
    expect(getByText(/Testapp is mounted!/i)).toBeInTheDocument();
  });
});

I wish I had the first test, but I have a problem: When i Run test I get a error: ReferenceError: System is not defined

/* single-spa@5.9.2 - SystemJS - prod */
    > 2 | System.register(["single-spa"], function (t) {
        | ^
      3 |   "use strict";
      4 |   var n;
      5 |   return {
taaniel
  • 53
  • 5

0 Answers0