Removing all try { ... } catch from *.spec.ts file.
vitest let's us have a better alternative
before
try {
// do something
} catch(err) {
expect(err).to.be.a(Error);
}
after
await expect(async () => {
// do something
}).rejects.toThrowError('the error')
This is very hard to add proper typecheck to an unknown, when we can have vitest do the job for us, and ensure we have a better error handling.
The expect error if Kubernetes reports error is removed because it was not testing anything, as no error is never raised, but since we only do expect in the catch block, the test was green.
I had to change the (extensionApi.process.exec as Mock) to vi.mocked(extensionApi.process.exec) because the test where not testing the right arguments
Removing all
try { ... } catch
from*.spec.ts
file.vitest let's us have a better alternative
before
after
This is very hard to add proper typecheck to an unknown, when we can have vitest do the job for us, and ensure we have a better error handling.
The
expect error if Kubernetes reports error
is removed because it was not testing anything, as no error is never raised, but since we only doexpect
in the catch block, the test was green.I had to change the
(extensionApi.process.exec as Mock)
tovi.mocked(extensionApi.process.exec)
because the test where not testing the right arguments