Cannot import component to write front-end test
Closed this issue · 4 comments
jacobtylerwalls commented
- Checkout archesproject/arches-lingo#39
- Add the following to stub out a test:
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 commented
import LoginForm from "@/arches_lingo/pages/LoginForm.vue";
The path is not correct?
jacobtylerwalls commented
Sorry, I posted the wrong error. I've edited it now. 🤦♂️
chrabyrd commented
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 commented