Testing text field input with Spectator

2.5k views Asked by At

I'm trying to test my directive with @ngneat/spectator version 6.1.1

it('should allow all numbers', () => {
    spectator = createDirective('<input appNumbersOnly type="number">')
    const input = spectator.query('input') as HTMLInputElement

    spectator.typeInElement('1234', input)

    expect(input.value).toHaveExactText('1234')
})

That always comes back with input.value being blank. I'm just getting started with spectator. What's the right way to perform this test?

1

There are 1 answers

0
tm1701 On

Just use:

expect(input.value).toEqual('1234');