remix-run / blues-stack

The Remix Stack for deploying to Fly with PostgreSQL, authentication, testing, linting, formatting, etc.
https://remix.run/stacks
MIT License
961 stars 236 forks source link

Issue with tests scanning postgres-data directory #28

Closed Tymek closed 2 years ago

Tymek commented 2 years ago

I had issues running rootless Docker in WSL2. Running postgress with user=root, postgres-data folder is created with root access, and npm run setup fails.

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Error: EACCES: permission denied, scandir '/src/█████/postgres-data/'
    at Object.readdirSync (node:fs:1392:3)
    at Object.readdir (/src/█████/node_modules/recrawl-sync/lib/fs.js:6:25)
    at crawl (/src/█████/node_modules/recrawl-sync/lib/recrawl.js:46:35)
    at crawl (/src/█████/node_modules/recrawl-sync/lib/recrawl.js:67:25)
    at /src/█████/node_modules/recrawl-sync/lib/recrawl.js:85:9
    at exports.crawl (/src/█████/node_modules/recrawl-sync/lib/recrawl.js:15:51)
    at findProjects (/src/█████/node_modules/vite-tsconfig-paths/dist/index.js:210:35)
    at Object.configResolved (/src/█████/node_modules/vite-tsconfig-paths/dist/index.js:68:24)
    at /src/█████/node_modules/vite/dist/node/chunks/dep-9c153816.js:71056:127
    at Array.map (<anonymous>) {
  errno: -13,
  syscall: 'scandir',
  code: 'EACCES',
  path: '/src/█████/postgres-data/'
}

I solved it with this patch:

diff --git a/package.json b/package.json
index 3472d91..6332ca9 100644
--- a/package.json
+++ b/package.json
@@ -30,7 +30,8 @@
   "eslintIgnore": [
     "/node_modules",
     "/build",
-    "/public/build"
+    "/public/build",
+    "/postgres-data"
   ],
   "dependencies": {
     "@node-rs/bcrypt": "^1.6.0",
diff --git a/vitest.config.ts b/vitest.config.ts
index de07a32..5fa4c92 100644
--- a/vitest.config.ts
+++ b/vitest.config.ts
@@ -6,10 +6,19 @@ import react from "@vitejs/plugin-react";
 import tsconfigPaths from "vite-tsconfig-paths";

 export default defineConfig({
-  plugins: [react(), tsconfigPaths()],
+  plugins: [react(), tsconfigPaths({ projects: ["tsconfig.json"] })],
   test: {
     globals: true,
     environment: "happy-dom",
     setupFiles: ["./test/setup-test-env.ts"],
+    exclude: [
+      "node_modules",
+      "dist",
+      ".idea",
+      ".git",
+      ".cache",
+      "build",
+      "postgres-data",
+    ],
   },
 });

I didn't solve issues with Cypress in WSL2, but I probably will not use Cypress.

sys13 commented 2 years ago

Had a similar issue. See my pull request: https://github.com/remix-run/blues-stack/pull/27

For Cypress on WSL2, I went through the WSL GUI docs. Doing a WSL update seemed to be enough, and didn't need to install nvidia drivers.

Tymek commented 2 years ago

I don't think it works on Win10, and I'm not switching to Win11 for that 😅. I'll probably run Playwright with VcXsrv.

BenMcH commented 2 years ago

This worked well for me on my forked blues stack :+1: Thank you!

kentcdodds commented 2 years ago

I've resolved this issue with a change to the vitest config :) Thanks!