Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat switch to jest #365

Merged
merged 3 commits into from Apr 22, 2020
Merged

Feat switch to jest #365

merged 3 commits into from Apr 22, 2020

Conversation

madarche
Copy link
Collaborator

Switch to Jest

@coveralls
Copy link

Coverage Status

Coverage decreased (-5.3%) to 93.37% when pulling 5b576c8 on madarche:feat-switch-to-jest into 0638485 on mozilla:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-5.3%) to 93.37% when pulling 5b576c8 on madarche:feat-switch-to-jest into 0638485 on mozilla:master.

@A-312
Copy link
Contributor

A-312 commented Apr 22, 2020

🤔

@madarche madarche merged commit 291cb01 into mozilla:master Apr 22, 2020
@A-312
Copy link
Contributor

A-312 commented Apr 22, 2020

I thought you refuse mocha because of the syntax expect(variable).to.be.something 😕

@madarche madarche deleted the feat-switch-to-jest branch April 22, 2020 17:09
@madarche
Copy link
Collaborator Author

madarche commented Apr 22, 2020

@A-312 I was convinced of the interest to switch from js-must. But should.js and chai.js were not good candidates because they both allow the use of property access for assertions cf. https://github.com/moll/js-must/#asserting-on-property-access. Chai.js documents the following as recommended expect(true).to.be.true; // Recommended cf. https://www.chaijs.com/api/bdd/ which is something we don't want to creep in Convict. And the good candidate also had to not (ab)use prototype. See also nodejs/node#32279. In the end there is only Jest that fits.

EDIT: Of course I should have mentioned Node TAP, which is secure and well designed, that I also considered. But Jest's matchers are more human readable at first glance than TAP's assertions.

@A-312
Copy link
Contributor

A-312 commented Apr 22, 2020

I read a new time and I understand now: expect(true).to.be.will_be_wrong_but_dont_throw; 😕 This is not a good thing :(

EDIT: They use proxy on their object to avoid this error

I tried:

            }
          }
        }
      }

      conf.validate()

      expect(conf.has('default')).to.be.lol
      expect(conf.getSchemaString()).to.equal(JSON.stringify(expected, null, 2))
      expect(conf.getSchemaString(true)).to.equal(JSON.stringify(nodeSchemaExpected, null, 2))
    })
  })

Seem fine:

  1) blueconfig get function
       .get()
         must parse with custom default substitute:
     Error: Invalid Chai property: lol. Did you mean "to"?
      at Object.proxyGetter [as get] (packages\blueconfig\node_modules\chai\lib\chai\utils\proxify.js:75:17)
      at Context.<anonymous> (packages\blueconfig\test\get-tests.js:133:40)
      at processImmediate (internal/timers.js:456:21)

I'm not sure to understand the 2nd argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants