-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[jest-each] Template table heading validation and extraction #8766
[jest-each] Template table heading validation and extraction #8766
Conversation
ac012f8
to
b3b66cd
Compare
Okay now I see what you mean. Just ignoring lines that do not match the expected format gives the possibility to put headlines in between, unrelated to any comment/skip API though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly breaking BTW if someone relies on multiple words between pipes
d8ea37f
to
b64b642
Compare
@jeysal It should work fine even if there is only one heading/param (see b64b642) 😄 I'm not sure I agree that it's a breaking change, I doubt anyone does depend on this behaviour and it definitely is a bug (well is an unintended behaviour) and needs fixing. I agree about not recommending people to add subheadings/additional text to the template - at least this way we do not put semantics (and code) around I suspect if we want to support a convention around this then it will need a little more thinking about. By fixing this behaviour it doesn't prevent people adding custom text should they want to in the meantime. |
Not with
perhaps, but quite possibly with
|
I don't think this should be considered a breaking change. Although it is true that someone's test would break with |
Are there any updates on this (and/or #8717)? |
@mattphillips ping 🙂 |
I think this is still good to go, but I would still say it's breaking because the example I gave in my last comment (using the behavior in headings) is actually not that far-fetched. Also, it's been lying around so long, might as well play it safe and put it into a major. |
aeed61d
to
2f75fb8
Compare
@jeysal rebase and land? |
@jeysal would you be able to take a look at CI? |
* master: (30 commits) chore: verify TS project references are correct (jestjs#10941) chore(deps): bump actions/setup-node from v2.1.2 to v2.1.3 (jestjs#10940) docs: Rectify typo in tutorialReactNative (jestjs#10930) chore: patch react-native jest preprocessor to avoid warning Ensure `toContain` only accepts strings when `received` is a string (jestjs#10929) chore: update lockfile after publish v27.0.0-next.2 Document and test custom, async, inline snapshot matcher (jestjs#10922) feat(transform): pass config options through to transformer (jestjs#10926) chore: bump eslint-config-prettier chore: run prettier using eslint chore: update lockfile after publish v27.0.0-next.1 fix: move binary file declaration from runtime to repl (jestjs#10925) chore(test-result): remove deprecated `sourcemap` property (jestjs#10355) chore: remove mapCoverage remainings; remove deprecated CLI options test (jestjs#9968) refactor(jest-runtime,jest-transform): add readonly for some class fields (jestjs#10918) chore: ensure single environment package as well chore: fix failing tests (jestjs#10924) chore: fix lint warning ...
I think the new snapshots it's trying to write look appropriate. pushed them |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Currently any additional words in a template will break
jest-each
's expected behaviour of injecting the template headings as variables to the test function.For example:
This test will fail as
expected
equalsundefined
.That is because currently
jest-each
splits on|
and removes whitespace so theexpected
key is actually deserialised toexpectedThistestdemonstratesjest-each
which is not correct.The proposed solution to this is to validate the headings to make sure there are no additional words in the first row (heading row). Any words appearing after the first row are simply ignored by
jest-each
.By ignoring the additional rows user's are able to add whatever they like - currently though
prettier
does strip out all additional text in the template after the first interpolation (${variable}
), perhaps it is worth investigating how to prevent that.This PR relates to point 2 in this comment
Test plan
See tests
EDIT: the above example will also now pass