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

Testing for ui #87

Open
JanSafronov opened this issue May 16, 2024 · 4 comments
Open

Testing for ui #87

JanSafronov opened this issue May 16, 2024 · 4 comments

Comments

@JanSafronov
Copy link

JanSafronov commented May 16, 2024

I am thinking about setting up testing for ui packages, will Jest framework be good enough for lens-up @Olszewskidev?
It has a few limitations with Vite so if it's ok I will configure babel for the ui packages?

@JanSafronov
Copy link
Author

#90 has an issue regarding import.meta property.
The error during testing reads:

Test suite failed to run

    packages/gallery-ui/src/services/GalleryApi.ts:6:14 - error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 
'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'.

    6     baseUrl: import.meta.env.VITE_GALLERY_SERVICE_URL,
                   ~~~~~~~~~~~
    packages/gallery-ui/src/services/GalleryApi.ts:26:74 - error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'.

    26                     const socket = new HubConnectionBuilder().withUrl(`${import.meta.env.VITE_GALLERY_SERVICE_URL}/hubs/gallery?galleryId=${galleryId}`).build();

@JanSafronov
Copy link
Author

I think adding the --experimental-vm-modules option to Jest testing command has partially resolved the issue but now there is a different error;

TypeError: Cannot read properties of undefined (reading 'VITE_GALLERY_SERVICE_URL')

      4 |
      5 | const baseQuery = fetchBaseQuery({
    > 6 |     baseUrl: import.meta.env.VITE_GALLERY_SERVICE_URL,
        |                              ^
      7 | });
      8 |
      9 | export const galleryApi = createApi({

      at packages/gallery-ui/src/services/GalleryApi.tsx:6:30

@JanSafronov
Copy link
Author

JanSafronov commented May 20, 2024

I will just use Vitest, it seems like Jest isn't worth the setup since there are hurdles with Vite, ts and Jest..

@JanSafronov
Copy link
Author

I also want to mock getGalleryPhotos in the galleryApi together with "Cypress" SignalR JS testing library if this is fine @Olszewskidev

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