canutin-desktop icon indicating copy to clipboard operation
canutin-desktop copied to clipboard

Tests: incorrect assertions for <select> components

Open fmaclen opened this issue 3 years ago • 0 comments

For example, these assertions are only testing that Security or Investments are one of the options but NOT that is the selected option:

assets.test.ts

const assetTypeSelect = page.locator('.formSelect__select[name=assetTypeId]');
const balanceGroupSelect = page.locator('.formSelect__select[name=balanceGroup]');

expect(await assetTypeSelect.textContent()).toMatch('Security');
expect(await balanceGroupSelect.textContent()).toMatch('Investments');

This doesn't work:

await expect(assetTypeSelect).toHaveValue('Security')

Because the value is the assetType.id and the number changes on every test run.

fmaclen avatar Sep 20 '22 18:09 fmaclen