Open DercilioFontes opened 3 days ago
I could make it work with this Vitest config pointing to cjs.
test: {
globals: true,
environment: 'jsdom',
setupFiles: 'src/setupTests.ts',
alias: {
'@azure/communication-react': path.resolve(
__dirname,
'node_modules/@azure/communication-react/dist/dist-cjs/communication-react/index.js',
),
},
},
});
Hi @DercilioFontes, thanks for filing this issue. I will have a discussion with my team about this and let you know.
@DercilioFontes Could you share your typescript config? You need to be using certain resolver to pick up the entry points. Just to note, VItest seems to work better with node.js environment
Hi @mgamis-msft
Sure.
tsconfig.json
{
"compilerOptions": {
"target": "ES2022",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"strict": true,
"noUnusedLocals": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"types": ["vitest/globals"]
},
"include": ["src", "types", "types/i18next.d.ts"],
"references": [{ "path": "./tsconfig.node.json" }]
}
tsconfig.node.json
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
Describe the bug; what happened? I updated the "@azure/communication-react" to version 1.21.0. Before, tests worked fine with version 1.18.1. However, I also updated Vite to v6 and Vitest to 2.1.6.
When trying to run the tests with Vitest, I get this error:
The build and app works fine.
I couldn't figure out how to solve it. Could it be a problem with how the package
package.json
is configured? I checked the package in this tool, and it suggests some changes. Could it help? https://publint.dev/@azure/communication-react@1.21.0However, it could also be some configuration with Vitest and Vite to fix it. Could you guys give some advice about that?
What are the steps to reproduce the issue? Probably a new project with Vite, Vitest and @azure/communication-react to test it.
What behavior did you expect? To resolve the import properly
If applicable, provide screenshots:
In what environment did you see the issue?
Is there any additional information?