FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test_runner: improve describe.only behavior by MoLow · Pull Request #52296 · nodejs/node · GitHub

/ node Public

test_runner: improve describe.only behavior - #52296

Merged
nodejs-github-bot merged 3 commits into
nodejs:mainfrom
MoLow:test-runner-only-improve
Apr 2, 2024
Merged

test_runner: improve describe.only behavior#52296
nodejs-github-bot merged 3 commits into
nodejs:mainfrom
MoLow:test-runner-only-improve

Conversation

MoLow commented Mar 31, 2024
edited
Loading

Copy link
Copy Markdown
Member

Supersedes #48932

this fixes two major issues with describe that will now run regardless of it not being marked with only:

  1. if a test is marked with only, it is not needed to mark all of its ancestors with only
  2. if a suite is marked as only, and no nested test is marked with only, all its decendents will run

this aligns the behavior with other test runners I have compared with

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/test_runner

nodejs-github-bot added needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Mar 31, 2024

MoLow commented Mar 31, 2024

Copy link
Copy Markdown
Member Author

some examples:

describe('1', () => {
  it('2');
  describe('3', () => {
    it('4');
    describe('5', () => {
      it('6');
      it.only('7');
    });
  });
});

===>

▶ 1
  ▶ 3
    ▶ 5
      ✔ 7 (0.30825ms)
    ▶ 5 (0.813458ms)
  ▶ 3 (1.103583ms)
▶ 1 (1.578209ms)
describe('1', () => {
  it('2');
  describe.only('3', () => {
    it('4');
    describe('5', () => {
      it('6');
      it('7');
    });
  });
});

===>

▶ 1
  ▶ 3
    ✔ 4 (0.414666ms)
    ▶ 5
      ✔ 6 (0.070375ms)
      ✔ 7 (0.112041ms)
    ▶ 5 (0.339458ms)
  ▶ 3 (1.070458ms)
▶ 1 (1.617208ms)

etc

cjihrig left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM, but it's probably worth updating some docs for this.

Comment thread doc/api/test.md
Comment thread doc/api/test.md Outdated
Comment thread doc/api/test.md Outdated
Comment thread doc/api/test.md
MoLow requested a review from atlowChemi April 1, 2024 18:47
MoLow added request-ci Add this label to start a Jenkins CI on a PR. author ready PRs that have at least one approval, no outstanding review comments, and a CI started. labels Apr 1, 2024
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 1, 2024

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Collaborator

MoLow added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Apr 1, 2024

rluvaton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can you add a test that before and after hooks are not running for unfocused suites? IIRC they do run when there are no tests in describe while I think they shouldn't in this case

MoLow commented Apr 2, 2024
edited
Loading

Copy link
Copy Markdown
Member Author

@rluvaton can you add these tests in a follow-up PR?. I am not sure what an unfocused suite is

rluvaton commented Apr 2, 2024

Copy link
Copy Markdown
Member

sure (what I meant with unfocused are suites that or not in the only scope)

MoLow commented Apr 2, 2024

Copy link
Copy Markdown
Member Author

FWIW this code

describe('describe 1', () => {
  before(() => console.log('before describe 1'))
  beforeEach(() => console.log('beforeEach describe 1'))
  it.only(async () => {
    console.log(1);
  })
  it('no', () => {});
  afterEach(() => console.log('afterEach describe 1'))
  after(() => console.log('after describe 1'))
})


describe('describe 2', () => {
  before(() => console.log('before describe 2'))
  beforeEach(() => console.log('beforeEach describe 2'))
  it('no', () => {});
  afterEach(() => console.log('afterEach describe 2'))
  after(() => console.log('after describe 2'))
})

outputs

before describe 1
beforeEach describe 1
1
afterEach describe 1
after describe 1
▶ describe 1
  ✔ <anonymous> (0.769792ms)
▶ describe 1 (5.330458ms)

which seems ok to me
CI is locked down so I prefer not to perform additional changes in this branch

nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 2, 2024
nodejs-github-bot merged commit ac9e5e7 into nodejs:main Apr 2, 2024

Copy link
Copy Markdown
Collaborator

Landed in ac9e5e7

MoLow deleted the test-runner-only-improve branch April 3, 2024 06:36

Copy link
Copy Markdown
Member

Can you please create a manual backport to v20x?

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants


Back | FazBrowse Home | New Git URL