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

Make --listTests return a new line separated list when not using --json #4229

Merged
merged 3 commits into from
Aug 10, 2017

Conversation

rogeliog
Copy link
Contributor

@rogeliog rogeliog commented Aug 9, 2017

Summary

#4214

This makes --listTests play better with tools like grep

Test plan

screen shot 2017-08-09 at 10 33 07 am

Copy link
Collaborator

@thymikee thymikee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rogelio's back!

@rogeliog
Copy link
Contributor Author

rogeliog commented Aug 9, 2017

@aaronabramov I didn't see #4212... Do you think this would play well with it?

@cpojer
Copy link
Member

cpojer commented Aug 9, 2017

Seems like this one is failing the tests, mind fixing it?

@@ -12,10 +12,17 @@
const runJest = require('../runJest');

describe('--listTests flag', () => {
it('causes tests to be printed out as JSON', () => {
it('causes tests to be printed in different lines', () => {
const {status, stdout} = runJest('list_tests', ['--listTests']);

expect(status).toBe(0);
expect(() => JSON.parse(stdout)).not.toThrow();
Copy link
Contributor

@aaronabramov aaronabramov Aug 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this assertion does'n seem to be correct any more, since it's not a JSON object now.
we should do something like:

expect(stdout.split('\n')).toHaveLength(1);
expect(stdout).toMatch('whatever.the.name.of.the.test.is.test.js');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I just added something similar but by snapshotting the output.. hope that is fine

@aaronabramov
Copy link
Contributor

@rogeliog i closed $4212 for now, we'll rethink the approach in the future, so i t should not be a problem

@rogeliog
Copy link
Contributor Author

rogeliog commented Aug 9, 2017

Btw, given that we are now using outputStream.write it doesn't add the extra blank line... should I add it or do we want to remove it?

@@ -0,0 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`--listTests flag causes tests to be printed in different lines 1`] = `
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's even better! <3

@rogeliog
Copy link
Contributor Author

rogeliog commented Aug 9, 2017

Oh, it seems that it is now failing because the tests ran in a different order... maybe I can remove that second dummy test file

@aaronabramov
Copy link
Contributor

aaronabramov commented Aug 9, 2017

@rogeliog split by \n and sort them!

@cpojer cpojer merged commit 3b6f22b into jestjs:master Aug 10, 2017
tushardhole pushed a commit to tushardhole/jest that referenced this pull request Aug 21, 2017
…on (jestjs#4229)

* Make `--listTests` return a new line separated list when not using `--json`

* Fix tests

* Sort dummy test files
@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants