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

feat: add test and fixture info to the TestController object and fixture hooks(closes #2826) #7736

Merged
merged 8 commits into from
Jun 7, 2023

Conversation

Artem-Babich
Copy link
Contributor

@Artem-Babich Artem-Babich commented May 29, 2023

Purpose

#2826

Currently, you cannot access any test/fixture information inside test and fixture hooks using public API. Fixture hooks cannot access this info even with private API.

Approach

Add corresponding members fixture: FixtureInfo, test:TestInfo to the TestController instance. Add the fixture info as a second argument to the fixture specific hooks.

References

#2826

API

type Metadata = Record<string, string>;

interface TestInfo {
    name: string;
    meta: Metadata;
}

interface FixtureInfo {
    name: string;
    meta: Metadata;
    path: string;
}
fixture`testFixture`
    .before(async (ctx, info: FixtureInfo) => {})
    .after(async (ctx, info: FixtureInfo) => {})
    .beforeEach(async t => {
        const testInfo: TestInfo = t.test
        const fixtureInfo: FixtureInfo = t.fixture;
    })
    .afterEach(async t => {
        const testInfo: TestInfo = t.test
        const fixtureInfo: FixtureInfo = t.fixture;
    })

test('SomeTest', async t => {})
    .before(async t => {
        const testInfo: TestInfo = t.test
        const fixtureInfo: FixtureInfo = t.fixture;
    })
    .after(async t => {
        const testInfo: TestInfo = t.test
        const fixtureInfo: FixtureInfo = t.fixture;
    })

Pre-Merge TODO

  • Write tests for your proposed changes
  • Add typings
  • Make sure that existing tests do not fail

@Artem-Babich Artem-Babich temporarily deployed to CI May 29, 2023 13:03 — with GitHub Actions Inactive
@Artem-Babich Artem-Babich temporarily deployed to CI May 30, 2023 07:06 — with GitHub Actions Inactive
@Artem-Babich Artem-Babich temporarily deployed to CI May 30, 2023 08:54 — with GitHub Actions Inactive
@Artem-Babich Artem-Babich changed the title feat: add test and fixture info to the TestController and fixture info to the fixture.before and .after hooks feat: add test and fixture info to the TestController object and fixture hooks(closes #2826) May 30, 2023
@Artem-Babich Artem-Babich temporarily deployed to CI May 30, 2023 09:47 — with GitHub Actions Inactive
src/utils/get-testrun-test-and-fixture-info.ts Outdated Show resolved Hide resolved
src/utils/get-testrun-test-and-fixture-info.ts Outdated Show resolved Hide resolved
src/utils/get-testrun-test-and-fixture-info.ts Outdated Show resolved Hide resolved
ts-defs-src/test-api/test-controller.d.ts Outdated Show resolved Hide resolved
@Artem-Babich Artem-Babich temporarily deployed to CI May 30, 2023 11:54 — with GitHub Actions Inactive
@Artem-Babich Artem-Babich requested a review from miherlosev May 30, 2023 11:57
@Artem-Babich Artem-Babich added AREA: docs An issue related to the product documentation. Awaiting documentation and removed AREA: docs An issue related to the product documentation. labels May 30, 2023
ts-defs-src/test-api/structure.d.ts Outdated Show resolved Hide resolved
ts-defs-src/test-api/structure.d.ts Outdated Show resolved Hide resolved
ts-defs-src/test-api/test-controller.d.ts Outdated Show resolved Hide resolved
ts-defs-src/test-api/test-controller.d.ts Outdated Show resolved Hide resolved
@Artem-Babich Artem-Babich temporarily deployed to CI May 31, 2023 08:47 — with GitHub Actions Inactive
@Artem-Babich Artem-Babich requested a review from titerman May 31, 2023 09:06
@Artem-Babich Artem-Babich temporarily deployed to CI June 6, 2023 06:36 — with GitHub Actions Inactive
@miherlosev miherlosev merged commit 5f25d05 into DevExpress:master Jun 7, 2023
@github-actions
Copy link

github-actions bot commented Jun 8, 2023

Release v3.0.0-rc.1 addresses this.

@Makavelic
Copy link

This breaks a lot of my tests because I use arrays, booleans, etc as data types as part of the meta object. For example:

test.meta({
testSkip: ["isBrowserstack", "firefox"]

Now it expects all properties to be string values only. Is this expected?

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jun 9, 2023
@Aleksey28
Copy link
Collaborator

Hi @Makavelic,

It is intended behavior. The documentation states that meta should have a string type. It was a bug before 3.0.0. Could you describe for what purpose you send an array as a value?

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Jun 12, 2023
@Makavelic
Copy link

My project has a custom testcafe runner that parses this value to determine whether a test should be skipped or not. An array is useful because I can add several conditions. I can refactor my runner code to just parse a string and split on ',' or something to get the desired effect.

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jun 13, 2023
@Artem-Babich Artem-Babich deleted the add-test-info branch June 14, 2023 06:47
@Artem-Babich Artem-Babich mentioned this pull request Jun 15, 2023
2 tasks
Aleksey28 pushed a commit that referenced this pull request Jun 15, 2023
## Purpose
Regression after #7736

## Approach
_Describe how your changes address the issue or implement the desired
functionality in as much detail as possible._

## References
_Provide a link to the existing issue(s), if any._

## Pre-Merge TODO
- [ ] Write tests for your proposed changes
- [ ] Make sure that existing tests do not fail
@Aleksey28
Copy link
Collaborator

Hi @Makavelic,

Thank you for reporting this issue. We fixed it and published 3.0.0-rc.2 with this fix.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants