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

Cannot import component to write front-end test #11332

Closed
jacobtylerwalls opened this issue Aug 13, 2024 · 4 comments
Closed

Cannot import component to write front-end test #11332

jacobtylerwalls opened this issue Aug 13, 2024 · 4 comments

Comments

@jacobtylerwalls
Copy link
Member

jacobtylerwalls commented Aug 13, 2024

diff --git a/arches_lingo/src/arches_lingo/pages/login/components/LoginForm.spec.ts b/arches_lingo/src/arches_lingo/pages/login/components/LoginForm.spec.ts
new file mode 100644
index 0000000..15810bb
--- /dev/null
+++ b/arches_lingo/src/arches_lingo/pages/login/components/LoginForm.spec.ts
@@ -0,0 +1 @@
+import LoginForm from "@/arches_lingo/pages/login/components/LoginForm.vue";
  • npm run vitest

Result

> vitest
> vitest --run --coverage


 RUN  v1.6.0 /Users/jwalls/prj/arches-lingo
      Coverage enabled with v8

 ✓ arches_lingo/src/arches_lingo/declarations.test.ts (0)
 ❯ arches_lingo/src/arches_lingo/pages/login/components/LoginForm.spec.ts (0)

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  arches_lingo/src/arches_lingo/pages/login/components/LoginForm.spec.ts [ arches_lingo/src/arches_lingo/pages/login/components/LoginForm.spec.ts ]
Error: Failed to resolve entry for package "arches". The package may have incorrect main/module/exports specified in its package.json.
 ❯ packageEntryFailure node_modules/vite/dist/node/chunks/dep-NjL7WTE1.js:46538:15
 ❯ resolvePackageEntry node_modules/vite/dist/node/chunks/dep-NjL7WTE1.js:46535:3
 ❯ tryNodeResolve node_modules/vite/dist/node/chunks/dep-NjL7WTE1.js:46351:16
 ❯ ResolveIdContext.resolveId node_modules/vite/dist/node/chunks/dep-NjL7WTE1.js:46101:19
 ❯ PluginContainer.resolveId node_modules/vite/dist/node/chunks/dep-NjL7WTE1.js:48893:17
 ❯ TransformPluginContext.resolve node_modules/vite/dist/node/chunks/dep-NjL7WTE1.js:49053:15
 ❯ normalizeUrl node_modules/vite/dist/node/chunks/dep-NjL7WTE1.js:63903:26
 ❯ async file:/Users/jwalls/prj/arches-lingo/node_modules/vite/dist/node/chunks/dep-NjL7WTE1.js:64042:39

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

 Test Files  1 failed | 1 passed (2)
      Tests  no tests
   Start at  13:11:24
   Duration  516ms (transform 61ms, setup 32ms, collect 3ms, tests 0ms, environment 516ms, prepare 93ms)
@chrabyrd
Copy link
Contributor

import LoginForm from "@/arches_lingo/pages/LoginForm.vue";

The path is not correct?

@jacobtylerwalls
Copy link
Member Author

Sorry, I posted the wrong error. I've edited it now. 🤦‍♂️

@chrabyrd
Copy link
Contributor

chrabyrd commented Aug 13, 2024

This is a good forcing function to have a wider conversation about getting certain data (settings and urls, namely) from Arches core into applications.

What's breaking the import arches from "arches"; in api.ts. It only works when manually test through some webpack trickery, and looks to not easy to mock for vitest since it's the pattern used for importing actual JS modules.This could be a good opportunity to land on a different (better) pattern for exposing urls and settings 👍

@jacobtylerwalls
Copy link
Member Author

Now tracked in #11373 for workaround and #11346 for better design.

@jacobtylerwalls jacobtylerwalls closed this as not planned Won't fix, can't repro, duplicate, stale Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

2 participants