enram / crow

Online tool to visualize birds detected by weather radars
https://crow.aloftdata.eu/
MIT License
0 stars 2 forks source link

Failed unit test #9

Closed peterdesmet closed 1 year ago

peterdesmet commented 1 year ago

Merging the changes from #8 broke one unit test:

/Users/peter_desmet/Coding/Repositories/enram/crow/src/helpers.ts:103
      obj[headers[j].trim()] = data[j].trim();
                     ^

TypeError: Cannot read properties of undefined (reading 'trim')
    at csvStringToObjs (/Users/peter_desmet/Coding/Repositories/enram/crow/src/helpers.ts:107:25)
    at parseCSVVpts (/Users/peter_desmet/Coding/Repositories/enram/crow/src/helpers.ts:123:13)
    at Object.parseVpts (/Users/peter_desmet/Coding/Repositories/enram/crow/src/helpers.ts:186:12)
    at /Users/peter_desmet/Coding/Repositories/enram/crow/src/components/Home.vue:454:110
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v19.8.1
ts-jest[versions] (WARN) Version 4.9.5 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions.
/Users/peter_desmet/Coding/Repositories/enram/crow/src/helpers.ts:103
      obj[headers[j].trim()] = data[j].trim();
                     ^

TypeError: Cannot read properties of undefined (reading 'trim')
    at csvStringToObjs (/Users/peter_desmet/Coding/Repositories/enram/crow/src/helpers.ts:107:25)
    at parseCSVVpts (/Users/peter_desmet/Coding/Repositories/enram/crow/src/helpers.ts:123:13)
    at Object.parseVpts (/Users/peter_desmet/Coding/Repositories/enram/crow/src/helpers.ts:186:12)
    at /Users/peter_desmet/Coding/Repositories/enram/crow/src/components/Home.vue:454:110
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v19.8.1
ts-jest[versions] (WARN) Version 4.9.5 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions.
/Users/peter_desmet/Coding/Repositories/enram/crow/src/helpers.ts:103
      obj[headers[j].trim()] = data[j].trim();
                     ^

TypeError: Cannot read properties of undefined (reading 'trim')
    at csvStringToObjs (/Users/peter_desmet/Coding/Repositories/enram/crow/src/helpers.ts:107:25)
    at parseCSVVpts (/Users/peter_desmet/Coding/Repositories/enram/crow/src/helpers.ts:123:13)
    at Object.parseVpts (/Users/peter_desmet/Coding/Repositories/enram/crow/src/helpers.ts:186:12)
    at /Users/peter_desmet/Coding/Repositories/enram/crow/src/components/Home.vue:454:110
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v19.8.1
ts-jest[versions] (WARN) Version 4.9.5 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions.
/Users/peter_desmet/Coding/Repositories/enram/crow/src/helpers.ts:103
      obj[headers[j].trim()] = data[j].trim();
                     ^

TypeError: Cannot read properties of undefined (reading 'trim')
    at csvStringToObjs (/Users/peter_desmet/Coding/Repositories/enram/crow/src/helpers.ts:107:25)
    at parseCSVVpts (/Users/peter_desmet/Coding/Repositories/enram/crow/src/helpers.ts:123:13)
    at Object.parseVpts (/Users/peter_desmet/Coding/Repositories/enram/crow/src/helpers.ts:186:12)
    at /Users/peter_desmet/Coding/Repositories/enram/crow/src/components/Home.vue:454:110
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v19.8.1
 FAIL  tests/unit/crow.spec.ts
  ● Test suite failed to run

    Call retries were exceeded

      at ChildProcessWorker.initialize (node_modules/jest-worker/build/workers/ChildProcessWorker.js:193:21)

Test Suites: 1 failed, 2 passed, 3 total
Tests:       5 passed, 5 total
Snapshots:   0 total
Time:        7.235s
Ran all test suites.

Ping @niconoe

niconoe commented 1 year ago

Will investigate right now!

niconoe commented 1 year ago

This is due to the fact that the some tests mock the radar data:

https://github.com/enram/crow/blob/104dd6d1ae117fb714c95a89254a13ba2e2fb1a9/tests/unit/crow.spec.ts#L97-L98

but not the actual configuration, so production config is used. Since in this fork, the behel radar is configured in the CSV format, the Home component actually gets data in the VOL2BIRD format but try to interpret it as CSV.

I was not able to just quickly overwrite configuration in the test files, since this config is loaded at a later stage by the Vue components via VueX config store.

The proper way to solve this is to mock the config file / config store for the tests, so they are not dependent anymore of the specific install configuration, which should be done in upstream (INBO) CROW.

peterdesmet commented 1 year ago

Thanks! We have https://github.com/inbo/crow/issues/192 to fix that more generally, for now it is fine to comment out those tests (for enram/crow only) as you have done in #11.