allure-js icon indicating copy to clipboard operation
allure-js copied to clipboard

fix: fix stepFn use this.parameter('xx', 'xx') do not work。

Open mind029 opened this issue 1 year ago • 1 comments

This PR contains the following updates:

  • Enable the attach method in the AllureCommandSteps class to support passing custom names.
  • Fix the issue in the step function of the AllureCommandSteps class where calling this.parameters('xx', 'xxx') doesn't take effect.

How to reproduce

example code

describe("page1", () => {
  test("test1", async () => {
    await allure.step('s1', async (s1) => {
      await s1.step('s1_1', async (s1_1) => {
        // this do not work
        s1_1.parameter('123', 's1_1')
        expect(1).toEqual(1)
      })

      expect(1).toEqual(1)
    })

    expect(1).toEqual(1)
  })
})

After running the test code, the output JSON result is as follows:

You can see that the content of s1_1.parameter is empty. It's expected to have data.

expect:

{
  "uuid": "c891d5db-7e97-4c9d-8467-f56e075a99cf",
  "historyId": "5d5234ef12c604daeee410751924bbf2:d41d8cd98f00b204e9800998ecf8427e",
  "status": "passed",
  "statusDetails": {},
  "stage": "finished",
  "steps": [
    {
      "name": "s1",
      "start": 1711010566264,
      "stop": 1711010566265,
      "stage": "finished",
      "status": "passed",
      "statusDetails": {},
      "attachments": [],
      "parameters": [],
      "steps": [
        {
          "name": "s1_1",
          "start": 1711010566264,
          "stop": 1711010566265,
          "stage": "finished",
          "status": "passed",
          "statusDetails": {},
          "attachments": [],
          "parameters": [
            {
              "name": "123",
              "value": "\"s1_1\"",
              "excluded": false
            }
          ],
          "steps": [],
          "description": ""
        }
      ],
      "description": ""
    }
  ],
  "attachments": [],
  "parameters": [],
  "labels": [
    {
      "name": "language",
      "value": "javascript"
    },
    {
      "name": "framework",
      "value": "jest"
    },
    {
      "name": "package",
      "value": "tests"
    },
    {
      "name": "thread",
      "value": "1"
    },
    {
      "name": "host",
      "value": "wang"
    },
    {
      "name": "parentSuite",
      "value": "page1"
    }
  ],
  "links": [],
  "start": 1711010566262,
  "name": "test1",
  "fullName": "page1 test1",
  "stop": 1711010566267
}

now:

{
  "uuid": "c891d5db-7e97-4c9d-8467-f56e075a99cf",
  "historyId": "5d5234ef12c604daeee410751924bbf2:d41d8cd98f00b204e9800998ecf8427e",
  "status": "passed",
  "statusDetails": {},
  "stage": "finished",
  "steps": [
    {
      "name": "s1",
      "start": 1711010566264,
      "stop": 1711010566265,
      "stage": "finished",
      "status": "passed",
      "statusDetails": {},
      "attachments": [],
      "parameters": [],
      "steps": [
        {
          "name": "s1_1",
          "start": 1711010566264,
          "stop": 1711010566265,
          "stage": "finished",
          "status": "passed",
          "statusDetails": {},
          "attachments": [],
          "parameters": [
         
          ],
          "steps": [],
          "description": ""
        }
      ],
      "description": ""
    }
  ],
  "attachments": [],
  "parameters": [],
  "labels": [
    {
      "name": "language",
      "value": "javascript"
    },
    {
      "name": "framework",
      "value": "jest"
    },
    {
      "name": "package",
      "value": "tests"
    },
    {
      "name": "thread",
      "value": "1"
    },
    {
      "name": "host",
      "value": "wang"
    },
    {
      "name": "parentSuite",
      "value": "page1"
    }
  ],
  "links": [],
  "start": 1711010566262,
  "name": "test1",
  "fullName": "page1 test1",
  "stop": 1711010566267
}

before:

image

The effect after fixing it is shown in the image:

image

mind029 avatar Mar 21 '24 08:03 mind029

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Mar 21 '24 08:03 CLAassistant

Thank you for the fix! Could you run yarn prettier:format && yarn lint:fix locally, to fix the failed job before we continue?

i fix it,you can continue。@epszaw

mind029 avatar Mar 21 '24 15:03 mind029

Good job, @mind029! Thank you for the contribution!

epszaw avatar Mar 25 '24 12:03 epszaw