Skip to content

ci: run tests on windows #269

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

timofei-iatsenko
Copy link
Contributor

@timofei-iatsenko timofei-iatsenko commented Dec 19, 2024

I have users reporting issues on windows. I configured smoke tests for the application on windows and indeed it's failing.

I searched through issues and there were a bunch of windows issues previously fixed, but tests in the CI were not added. That's why I'm adding them to showcase the problems on windows.

Regarding current issue, example of failing WF is here

https://github.com/timofei-iatsenko/keycloakify-emails/actions/runs/12416203815/job/34664284560

It's failing with:

ReferenceError: require is not defined
    at moduleImport (file:///D:/a/keycloakify-emails/keycloakify-emails/node_modules/.pnpm/jsx-email@2.5.3_patch_hash=lw572etmmjvpxarowkqqptjobm_@jsx-email+plugin-inline@1.0.1_@jsx-ema_3cnz4xvaxhfemvgnnu2s7rzzne/node_modules/jsx-email/src/config.ts:201:6)
    at Object.search (D:\a\keycloakify-emails\keycloakify-emails\node_modules\.pnpm\lilconfig@3.1.2\node_modules\lilconfig\src\index.js:222:23)
    at loadConfig (file:///D:/a/keycloakify-emails/keycloakify-emails/node_modules/.pnpm/jsx-email@2.5.3_patch_hash=lw572etmmjvpxarowkqqptjobm_@jsx-email+plugin-inline@1.0.1_@jsx-ema_3cnz4xvaxhfemvgnnu2s7rzzne/node_modules/jsx-email/src/config.ts:219:14)
    at render (file:///D:/a/keycloakify-emails/keycloakify-emails/node_modules/.pnpm/jsx-email@2.5.3_patch_hash=lw572etmmjvpxarowkqqptjobm_@jsx-email+plugin-inline@1.0.1_@jsx-ema_3cnz4xvaxhfemvgnnu2s7rzzne/node_modules/jsx-email/src/renderer/render.ts:46:16)
    at Object.getTemplate (file:///D:/a/keycloakify-emails/keycloakify-emails/example/emails/templates/email-test.tsx:35:10)
    at renderTemplate (file:///D:/a/keycloakify-emails/keycloakify-emails/dist/index.mjs:68:20)
    at renderThemeVariant (file:///D:/a/keycloakify-emails/keycloakify-emails/dist/index.mjs:162:5)

I dug into jsx-email sourcecode, it seems problem is here:

const moduleImport = async (id: string) => {
try {
const mod = await import(id);
return mod;
} catch (e) {
try {
return require(id);
} catch (error) {
if (
(error as any).code === 'ERR_REQUIRE_ESM' ||
(error instanceof SyntaxError &&
error.toString().includes('Cannot use import statement outside a module'))
) {
throw e;
}
throw error;
}

The first try catch is actually hiding the original issue. I patched the sourcecode and added another throw to reveal the original error message and got this one:

Error: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'

Worth mentioning that similar issue was not reproducible in my test suite in Vite, i suppose it's because vite is doing some pre-processing for files and nodejs receives not original import.

Component / Package Name:

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

If yes, please include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

List any relevant issue numbers:

Description

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

Successfully merging this pull request may close these issues.

1 participant