Self-hosted test build (npm t) fails...
# support
a
Hey, not sure if this should go as a bug report on Github or if it's best here to get some troubleshooting if the error's on my end. I have a physical box (Optiplex 7010) running AlmaLinux 9 that I've installed the dependencies on in order to set up medplum. I've updated
packages/server/medplum.config.json
as required, but I'm getting a build failure when I run
npm t
(as a somewhat aside - I have not used npm/typescript/NodeJS before, so is it usual to require
sudo
to run
npm t
? If I try without I get a permissions error...) Anyway, as for the test build, here's the error I'm seeing:
Copy code
@medplum/core:test: Summary of all failing tests
@medplum/core:test:  FAIL  src/format.test.ts
@medplum/core:test:   ● Format date
@medplum/core:test:     expect(received).toEqual(expected) // deep equality
@medplum/core:test:     Expected: "6/1/2021"
@medplum/core:test:     Received: "2021-06-01"
...
@medplum/core:test:       at Object.toEqual (src/format.test.ts:247:36)
@medplum/core:test: 
@medplum/core:test:   ● Format Money
@medplum/core:test:     expect(received).toBe(expected) // Object.is equality
@medplum/core:test:     Expected: "$10.10"
@medplum/core:test:     Received: "US$10.10"
To me it looks like it could be a localization issue? I'm in Canada, so my default date format is a bit different, but shouldn't the software account for that with other regionalization? Or is there something in the software that isn't working right on AlmaLinux (RHEL rather than Debian based). Anyway, after that I get a lot more errors in the log:
Copy code
@medplum/docs:build: ● Client █████████████████████████ building (10%) 0/1 entries 6/33 dependencies 0/5 modules 5 active 
@medplum/docs:build:  babel-loader › ../../node_modules/@docusaurus/core/lib/client/exports/ExecutionEnvironment.js
@medplum/docs:build: ● Server █████████████████████████ building (10%) 0/1 entries 5/10 dependencies 0/5 modules 5 active 
@medplum/docs:build:  babel-loader › ../../node_modules/@docusaurus/core/lib/client/BrokenLinksContext.js
...
@medplum/core:test: Test Suites: 1 failed, 53 passed, 54 total
@medplum/core:test: Tests:       2 failed, 115 skipped, 1460 passed, 1577 total
...
@medplum/core:test: npm ERR! Lifecycle script `test` failed with error: 
@medplum/core:test: npm ERR! Error: command failed 
@medplum/core:test: npm ERR!   in workspace: @medplum/core@3.1.2 
@medplum/core:test: npm ERR!   at location: /home/<username>/medplum/packages/core 
@medplum/core:test: ERROR: command finished with error: command (/home/<username>/medplum/packages/core) /bin/npm run test exited (1)
...
@medplum/app:build: vite v5.2.8 building for production...
../../node_modules/@mantine/core/esm/core/utils/get-env/get-env.mjs (1:0): Error when using sourcemap for reporting an error: Can't resolve original location of error.
../../node_modules/@mantine/hooks/esm/use-focus-trap/use-focus-trap.mjs (1:0): Error when using sourcemap for reporting an error: Can't resolve original location of error.
../../node_modules/@mantine/hooks/esm/use-focus-trap/tabbable.mjs (1:0): Error when using sourcemap for reporting an error: Can't resolve original location of error.
...
@medplum/app:build: (!) Some chunks are larger than 500 kB after minification. Consider:
@medplum/app:build: - Using dynamic import() to code-split the application
@medplum/app:build: - Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
@medplum/app:build: - Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
@medplum/app:build: ✓ built in 15.35s
@medplum/core#test: command (/home/<username>/medplum/packages/core) /bin/npm run test exited (1)

 Tasks:    27 successful, 45 total
Cached:    7 cached, 45 total
  Time:    1m57.317s 
Failed:    @medplum/core#test

 ERROR  run failed: command  exited (1)
Appreciate any advice anyone here can offer! Thanks!
Well, I solved my issue with user permissions. Turns out it was postgreSQL requiring Ident authentication, with the username medplum when there is no Linux user that matches that name. So I switched to sha256 auth, reset the passwords under postgreSQL to be hashed and now that's all solved. Still haven't figured out this issue with the test build though - I can't seem to find where the locale is defined if there is no locale actually passed to the script. It seems to be getting an international format but expecting a default non-international code if no locale is set. At least, that's what it looks like to me - like I said though, not familiar with Node/TS so I could be wrong....
r
@asclepiadae - I think your diagnosis is correct that this seems to be a localization issue
Right now Medplum is primarily tested when running in the US locale, but should function in other regions as well. However, b/c we run our tests in the US region, our expected outputs are formatted in US formats
If you're just interested in producting build artificats, you may be interested in running
npm run build:fast
a
hm, I get a missing script error with that... 😆
Copy code
npm ERR! Lifecycle script `build:fast` failed with error: 
npm ERR! Error: Missing script: "build:fast"

To see a list of scripts, run:
  npm run 
npm ERR!   in workspace: @medplum/server@3.1.2
Copy code
Lifecycle scripts included in @medplum/server@3.1.2:
  start
    node --require ./dist/otel/instrumentation.js dist/index.js
  test
    jest --runInBand

available via `npm run-script`:
  build
    npm run clean && tsc --project tsconfig.build.json
  clean
    rimraf dist
  dev
    ts-node-dev --poll --respawn --transpile-only --require ./src/otel/instrumentation.ts src/index.ts
Any thoughts on how I'd go about overriding the locale issue? I can fairly easily pull those tests so that it passes, just not sure if that will break things in the actual build...
r
> hm, I get a missing script error with that... 😆 @asclepiadae sorry for the delay in getting back to you. For this, just wanted to check - are you running
build:fast
from the root medplum directory?
183 Views