river-build / river

https://river-sample-app.vercel.app
MIT License
23 stars 5 forks source link

move sdk to vitest #1582

Open miguel-nascimento opened 5 days ago

miguel-nascimento commented 5 days ago

I'm breaking #1462 into small PRs

Moving the sdk package from jest to vitest.

Why:

Most changes of this PR includes:

Vitest doesn't support test groups. We're managing test suites based on the filename

previously now running env
no group <name>.test.ts unit tests
@group main <name>.test.multi_ne.ts multi_ne
@group with-entitlements <name>.test.multi.ts multi
@group with-v2-entitlements <name>.test.multi.v2.ts multi_v2

Alternative: Filename gets longer with the filename test suite management We could filter tests by the test name pattern

previously suggestion running env
no group describe('unit/...) unit tests
@group main describe('multi_ne/...) multi_ne
@group with-entitlements describe('multi/...) multi
@group with-v2-entitlements describe('multi_v2/...) multi_v2

What do you guys think?

vercel[bot] commented 5 days ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
river-sample-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 20, 2024 10:31pm
texuf commented 5 days ago

are you sure these tests are passing, the multinode_ent all have error messages and yellow checks. Is a yellow check a pass?

   ✓ member.test.ts - queue update > queue update metadata 4247ms
stderr | src/sync-agent/spaces/spaces.test.multi.ts > spaces.test.ts > create/leave/join space
AggregateError: 
    at internalConnectMultiple (node:net:1118:18)
    at afterConnectMultiple (node:net:1685:7) {
  code: 'ECONNREFUSED',
  [errors]: [
    Error: connect ECONNREFUSED ::1:3000
        at createConnectionError (node:net:1648:14)
        at afterConnectMultiple (node:net:1678:16) {
      errno: -111,
      code: 'ECONNREFUSED',
      syscall: 'connect',
      address: '::1',
      port: 3000
    },
    Error: connect ECONNREFUSED 127.0.0.1:3000
        at createConnectionError (node:net:1648:14)
        at afterConnectMultiple (node:net:1678:16) {
      errno: -111,
      code: 'ECONNREFUSED',
      syscall: 'connect',
      address: '127.0.0.1',
      port: 3000
    }
  ]
}
texuf commented 5 days ago

looks like vitest just prints errors and warnings, probably a good thing! we should fix errors and warnings. Did you confirm that the number of tests executed is the same as a non vitest pr? i.e.:

Test Files  35 passed | 1 skipped (36)
      Tests  178 passed | 2 skipped (180)
texuf commented 5 days ago

@sergekh2 suggested the folder option for tests. I'm actually fine with it if we just put a tests folder so that it's tests/<unit/multi/multi_ne/multi_v2> etc... i think that makes way more sense.

miguel-nascimento commented 4 days ago

Multinode > Run SDK Tests (without entitlements)

Jest

Test Suites: 42 passed, 42 of 71 total
Tests:       1 skipped, 190 passed, 191 total
Snapshots:   0 total
Time:        443.342 s
Ran all test suites.

Vitest:

 Test Files  35 passed | 1 skipped (36)
      Tests  178 passed | 2 skipped (180)
   Start at  22:30:00
   Duration  168.93s (transform 1.85s, setup 1.21s, collect 36.05s, tests 843.55s, environment 12.01s, prepare 2.87s)

There are 7 tests suite missing update: those tests are running in unit tests instead of multi

Multinode Ent > Run SDK Tests (with entitlements)

Jest

Test Suites: 23 passed, 23 of 71 total
Tests:       123 passed, 123 total
Snapshots:   0 total
Time:        1085.794 s

Vitest

 Test Files  25 passed (25)
      Tests  130 passed (130)
   Start at  22:32:49
   Duration  774.43s (transform 1.82s, setup 727ms, collect 27.61s, tests 1744.49s, environment 7.95s, prepare 1.68s)

I'll check what are the tests that vitest is running ahead.

Multinode Ent Legacy > Run River Tests against Legacy Spaces

Jest

Test Suites: 20 passed, 20 of 71 total
Tests:       104 passed, 104 total
Snapshots:   0 total
Time:        1068.463 s

Vitest

 Test Files  22 passed (22)
      Tests  111 passed (111)
   Start at  22:32:58
   Duration  773.21s (transform 1.94s, setup 772ms, collect 27.66s, tests 1417.47s, environment 7.37s, prepare 1.65s)

I'll check what are the tests that vitest is running ahead.