Skip to content

Unreliable unit tests #1908

@friederbluemle

Description

@friederbluemle

Some unit test randomly appear to fail in certain conditions (for example when using Node.js 20 or later).

Example 1 (unit tests related to code push):

https://github.com/friederbluemle/electrode-native/actions/runs/9495253376/job/26167127192#step:6:520

https://dev.azure.com/ElectrodeNative/Electrode%20Native/_build/results?buildId=7222&view=logs&j=195f2670-0934-542b-f708-55083700808e&t=aee57a02-7e04-5dc7-01bc-f6a4fd498e68&l=2012

  340 passing (621ms)
  1 pending
  3 failing

  1) getCodePushInitConfig
       should return the access key from code push config if keys are present in both config files:
     AssertionError: expected undefined to equal '1e2509c78c4f94c25e69131a0a5e5be3b7d2927b'
      at Context.<anonymous> (test/getCodePushInitConfig-test.ts:40:53)
      at processImmediate (node:internal/timers:478:21)

  2) getCodePushInitConfig
       should return the access key from code push config if key is not present in .ernrc:
     AssertionError: expected undefined to equal '1e2509c78c4f94c25e69131a0a5e5be3b7d2927b'
      at Context.<anonymous> (test/getCodePushInitConfig-test.ts:55:53)
      at processImmediate (node:internal/timers:478:21)

  3) getCodePushSdk
       should not throw if an access key exists:
     AssertionError: expected [Function: getCodePushSdk] to not throw an error but 'Error: Unable to get the CodePush config to use' was thrown
      at Context.<anonymous> (test/getCodePushSdk-test.ts:43:40)
      at processImmediate (node:internal/timers:478:21)

Example 2 (two different unit tests related to CauldronHelper):

  460 passing (6s)
  2 failing

  1) CauldronHelper.js
       getYarnLock
         should return the yarn lock if found for key:
     Error: ENOENT: no such file or directory, open '/var/folders/xb/4lt2zppd3cnc6qhcc09wxb8r0000gn/T/tmp-32217-3fMBmodIH4Ix/yarnlocks/f0bf18dc-98ce-4548-bb2b-3ec35616091a'
      at Object.open (node:internal/fs/sync:78:18)
      at Object.openSync (node:fs:565:17)
      at Object.readFileSync (node:fs:445:35)
      at EphemeralFileStore.getFile (src/EphemeralFileStore.ts:57:17)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at Context.<anonymous> (test/CauldronHelper-test.ts:785:24)

  2) CauldronHelper.js
       updateYarnLock
         should update the yarn lock:
     Error: ENOENT: no such file or directory, open '/var/folders/xb/4lt2zppd3cnc6qhcc09wxb8r0000gn/T/tmp-32217-Lp4GZ8AHiQVY/yarnlocks/f2886fd3-3824-4e2b-ac07-2f116b691674'
      at Object.open (node:internal/fs/sync:78:18)
      at Object.openSync (node:fs:565:17)
      at Object.readFileSync (node:fs:445:35)
      at EphemeralFileStore.getFile (src/EphemeralFileStore.ts:57:17)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at Context.<anonymous> (test/CauldronHelper-test.ts:920:24)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions