hippware / rn-chat

MIT License
5 stars 0 forks source link

WIP: base for #4883 #4937

Open aksonov opened 4 years ago

aksonov commented 4 years ago

@southerneer Maybe you have idea why original formValidation test 'first name ends with space'' works well but the same firstName doesn't throw error from my refactored copy?

P. S. Btw, I found that rn-chat tests are not run and fail now

southerneer commented 4 years ago

The problem is that the original test was giving a false positive.

  it('first name ends with space', async () => {
    try {
      await validateProfile({firstName: 'Eric '})
    } catch (err) {
      expect(err).toStrictEqual({
        firstName: ['First name can only contain alphabet characters'],
      })
    }
  })

Inside the try block I should have expected it to throw an error like this...

expect(await validateProfile({firstName: 'Eric '})).toThrow()

So while the correct error may have been thrown at some point in the past, it was lost in future revisions but the test kept on saying everything was ok.

bengtan commented 4 years ago

I found that rn-chat tests are not run and fail now

I dug into this.

In PR 4187 ('upgrade to RN0.61') there was this comment:

https://github.com/hippware/rn-chat/pull/4187#issuecomment-535697542

I'm going to deactivate jest snapshot tests for now, create a ticket, and reactivate later when they're fixed.

followed by commit f4c7c43c which removed ... npm run jestCI from the CLI yarn test

PR 4187 was merged and into 4.27.0.

I'm guessing that when @southerneer disabled the jest snapshot tests (*.test.tsx) by removing ... npm run jestCI, he didn't realise it also disabled HomeStore.test.ts and formValidation.test.ts?

So ... maybe consider doing the following?:

  1. Re-enable HomeStore.test.ts and formValidation.test.ts again. An easy way would be to copy them into the wocky tests.
  2. Re-visit jest snapshot tests again (optional)? (Probably as a separate ticket/PR.)
  3. Review the scripts in package.json as the naming/structure of yarn jestCI, yarn jestWockyCI etc. is a bit out of date.