Use functions for test samples
Instead of directly exporting JS objects in test/testsamples.js
, the samples should be functions that return objects:
// Bad
export const typeSample = { id: 'typeid', name: 'folder' }
// Good
export const typeSample = () => ({ id: 'typeid', name: 'folder' })
This avoids some very annoying issues due to Vue component tests: when any sample gets added to a component's data or is watched in some way, said sample is updated to use getters and setters. This causes strange assertion errors in tests like Inputs identical but not reference equal
. Currently, to avoid this, we need to add cloneDeep
calls (from lodash) anywhere we use a sample that will be sent to a component, and missing one can lead to hours wasted looking for the one component test that is completely unrelated to your merge request and is breaking your stuff. I am definitely not typing this out of frustration.