I have a utils/helpers.ts file with a bunch of different functions in it used across our app.
We are starting to implement vitest testing, and I want to create an example test using one of our util functions, so I am importing the function like so:
import { expect, test } from 'vitest' import { formatDateTime } from '../../utils/helpers.ts'
test('formatDateTime should return correct date format', () => { expect(formatDateTime(new Date('2023-09-15T12:00:00Z'))).toBe('2023-09-15 12:00:00') })
But there's a ton of other tests in that file that I don't want to run during this example test, which break because they need a bunch of imports from the parent files in which they're used across the site which don't exist inside of my test.
When I try to run npm run test, it breaks because of the missing arguments in preceding functions within utils/helpers.ts, but I don't want those functions to run at all!
Why does vitest run the entire helper file rather than only formatDateTime()? I'm so confused!
The issue is that previous functions int hat helpers file are computed functions, which only work when vue computed is imported into the file, but as this is just an example test I just want to be testing the simple formatDateTime function in the same file without running the other functions