Conversation
|
Edit: oh, I didn't see that you have already installed a testing framework in a subfolder. You of course could move the tests down there. |
commit: |
There was a problem hiding this comment.
cubic found 4 issues across 7 files. Review them in cubic.dev
React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.
| testTimeout: 60000, | ||
| hookTimeout: 60000, | ||
| // Run all test files sequentially to avoid DynamoDB table race conditions | ||
| fileParallelism: false, |
There was a problem hiding this comment.
'fileParallelism' is not a documented Vitest configuration option. The correct option to control parallelism is 'threads' or 'sequence.concurrent'. Using undocumented options may have no effect and could cause confusion.
| if (!Array.isArray(current) || current.length <= index - 1) { | ||
| return; | ||
| } | ||
| current = current[index - 1]; |
There was a problem hiding this comment.
The code accesses current[index - 1], but index is already zero-based. This will result in off-by-one errors, returning the wrong element or undefined. It should use current[index].
| current = current[index - 1]; | |
| current = current[index]; |
| return; | ||
| } | ||
|
|
||
| if (!Array.isArray(current) && index === 1) { |
There was a problem hiding this comment.
This condition is incorrect: it checks for index === 1, but array indices are zero-based. It also skips the array check if index is 1, which is inconsistent with the rest of the function and may cause incorrect traversal or missed elements.
| if (!Array.isArray(current) && index === 1) { | |
| if (!Array.isArray(current) && index > 0) { continue; } |
| * @param location - The dot-separated path (e.g., 'CrossIndustryInvoice[0].TypeCode[1]') | ||
| * @returns The value at the specified location, or undefined if not found | ||
| */ | ||
| export function getValueFromXmlJson(source: any, location: string) { |
There was a problem hiding this comment.
The function does not ignore XML namespaces when matching tags, despite the documentation stating it should. It directly accesses current[tag], which will not work if the keys include namespaces (e.g., 'ram:TypeCode'). This can cause the function to fail to retrieve values as intended.
|
Thanks, this was very helpful! |
Here's an Idea on how you could add output validation testing to your project.
We are using the java library "mustang" - you need to have java installed, the jar file is downloaded automatically during test setup.
Alternatively we could implement this using testcontainers (and the setup installed in there).
Here you could add multiple scenarios and validate their output.
Just a quick draft, nothing sophisticated