kiegroup / act-js

A node.js wrapper for nektos/act to programmatically run your github actions locally
Apache License 2.0
56 stars 10 forks source link

`mockApi` failing on WSL2 #25

Open shubhbapna opened 1 year ago

shubhbapna commented 1 year ago

Describe the bug It seems like mockApi is failing in a WSL2 windows 11 environment

To Reproduce

Workflow ```yaml name: Act Push Test 1 on: push jobs: push1: runs-on: ubuntu-latest steps: - run: echo "push 1" - name: secrets run: echo $TEST1 env: TEST1: ${{secrets.SECRET1}} - name: env run: echo $ENV1 - name: pass run: echo "pass" - name: fail run: echo "fail" && exit 1 ```
Code Taken from [act.test.ts](https://github.com/kiegroup/act-js/blob/main/test/unit/act/act.test.ts#L106) ```typescript test("run with proxy", async () => { const mockapi = new Mockapi({ google: { baseUrl: "http://google.com", endpoints: { root: { get: { path: "/", method: "get", parameters: { query: [], path: [], body: [], }, }, }, }, }, }); const act = new Act(); const output = await act.runJob("mock", { workflowFile: resources, mockApi: [ mockapi.mock.google.root .get() .setResponse({ status: 200, data: "mock response" }), ], }); expect(output).toStrictEqual([ { name: "Main https api call", status: 0, output: expect.stringMatching(/.+/), }, { name: "Main http api call", status: 0, output: "mock response", }, ]); }); ```

Expected behavior Test should pass. Test passes in other linux environments

Logs

run › run with proxy

    expect(received).toStrictEqual(expected) // deep equality

    - Expected  - 7
    + Received  + 2

      Array [
        Object {
          "name": "Main https api call",
    -     "output": StringMatching /<HTML><HEAD>.+/,
    -     "status": 0,
    -   },
    -   Object {
    -     "name": "Main http api call",
    -     "output": "mock response",
    -     "status": 0,
    +     "output": "",
    +     "status": 1,
        },
      ]

      133 |       ],
      134 |     });
    > 135 |     expect(output).toStrictEqual([
          |                    ^
      136 |       {
      137 |         name: "Main https api call",
      138 |         status: 0,

      at Object.<anonymous> (test/unit/act/act.test.ts:135:20)