4

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?

Gargoyle
  • 9,590
  • 16
  • 80
  • 145
  • Have you managed to solve this? I have a bit different issue - I seem to be able to set the value, however Angular's form.valid property does not seem to be updated. – Kirill G. Jan 01 '22 at 02:54

1 Answers1

1

Just use:

expect(input.value).toEqual('1234');
tm1701
  • 7,307
  • 17
  • 79
  • 168