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

Describe issues related to testing in vitest #296

Open
blcham opened this issue Mar 28, 2024 · 2 comments
Open

Describe issues related to testing in vitest #296

blcham opened this issue Mar 28, 2024 · 2 comments
Assignees

Comments

@blcham
Copy link
Collaborator

blcham commented Mar 28, 2024

When testing record-manager-ui using vitest, SForms library was causing issues. Thus we had to configure it in vite.config.js as follows:

 test: {
    server: {
      deps: {
        inline: ["@kbss-cvut/s-forms"],
      },
    },
  },
@blcham
Copy link
Collaborator Author

blcham commented Mar 28, 2024

@shellyear do not try to solve the issue just describe some insides/intuition about the error, e.g.:

  • build vs. runtime error in tests + what errors it causes + possibly why?
  • do you think it is because of bad bundling of SForms lib?

@blcham blcham changed the title Fix Describe issues related to testing in vitest Mar 28, 2024
@blcham blcham self-assigned this Mar 28, 2024
@shellyear shellyear self-assigned this Mar 28, 2024
@blcham blcham removed their assignment Mar 28, 2024
@shellyear
Copy link
Contributor

shellyear commented Mar 29, 2024

@blcham With jest it was configured, so that ".css" files were mocked https://github.com/kbss-cvut/record-manager-ui/blob/be13081c4558cecdac9adc7cfd24b18ebd57b9af/jest.config.js in tests/**/styleMock.
Vitest can process and resolve .css files only with vmThreads and vmForks pools configured %, but using those pools comes with a lot of issues. By inlining @kbss-cvut/s-forms we make sure, that Vitest (esbuild) will not try to resolve files from @kbss-cvut/s-forms using imports, but will directly inline them into the source code during compiling.

https://vitest.dev/config/#server-deps-inline
Vite will process inlined modules. This could be helpful to handle packages that ship .js in ESM format (that Node can't handle).
So the root problem is likely to be related to the @triply/yasgui package, and how is ships it's modules.

Also skipped tests rely on css classes (e.g Dashboard.spec.jsx), so I think including resolving .css files is necessary, if we need to include those skipped tests in the future.

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

2 participants