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

Add POC support for tagged template literals #5

Closed
wants to merge 1 commit into from

Conversation

mattphillips
Copy link
Owner

Proves the concept of using tagged template literals for data tables in Jest.

Related to jestjs/jest#6082

Example of how tests could be written:

describe('.add', () => {
  each`
    a    | b    | expected
    ${0} | ${0} | ${0}
    ${0} | ${1} | ${1}
    ${1} | ${1} | ${2}
  `.test('returns $expected when given $a and $b', ({ a, b, expected }) => {
    expect(a + b).toBe(expected);
  });
});

describe('.join', () => {
  each`
    array        | delimiter | expected
    ${[0, 1, 2]} | ${'*'}    | ${'0*1*2'}
  `.test('returns $expected when given $array is joined with $delimiter', ({ array, delimiter, expected }) => {
    expect(array.join(delimiter)).toBe(expected);
  });
});

↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

screen shot 2018-04-28 at 01 11 24

/cc @SimenB

@SimenB
Copy link

SimenB commented Apr 28, 2018

This is cool!

@mattphillips mattphillips deleted the each-template-literal branch May 8, 2018 09:45
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.

2 participants