Today I Learned

hashrocket A Hashrocket project

Table tests with Jest

Jest has a nice helper function that allow us to run table tests. Check this out:

const cases = [
  ["", true],
  ["", true],
  ["", false],
  ["user@", false],
  ["", false],

test.each(cases)("validateEmail(%s) should be %s", (email, expected) => {

Here's the documentation

See More #javascript TILs
Looking for help? At Hashrocket, our JavaScript experts launch scalable, performant apps on the Web, Android and iOS. Contact us and find out how we can help you.