Gargoyle
Gargoyle

Reputation: 10324

Testing text field input with Spectator

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?

Upvotes: 4

Views: 3040

Answers (1)

tm1701
tm1701

Reputation: 7581

Just use:

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

Upvotes: 1

Related Questions