pact-foundation / pact-workshop-js

Pact JS workshop - learn Pact in 60 minutes
https://pact.io
148 stars 154 forks source link

Errors when running the tests in step 4 #1

Closed LongJeongS closed 3 years ago

LongJeongS commented 4 years ago

Hi there,

Whilst following the tutorial, I am getting the following errors when i run the tests using the command: npm run test:pact --prefix consumer. I have all the node_modules installed, im using node version 10.8.0

FAIL src/api.pact.spec.js (6.973s)
  API Pact test
    getting all products
      ✕ products exists (6ms)
      ✕ no products exists (1ms)
      ✕ no auth token (1ms)
    getting one product
      ✕ ID 10 exists (1ms)
      ✕ product does not exist (1ms)
      ✕ no auth token

  ● API Pact test › getting all products › products exists

    Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

      at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

  ● API Pact test › getting all products › products exists

    TypeError: Cannot read property 'addInteraction' of undefined

      30 |
      31 |             // set up Pact interactions
    > 32 |             await provider.addInteraction({
         |                            ^
      33 |                 state: 'products exist',
      34 |                 uponReceiving: 'get all products',
      35 |                 withRequest: {

      at Pact.addInteraction (node_modules/@pact-foundation/src/httpPact.ts:102:29)
      at Object.test (src/api.pact.spec.js:32:28)

  ● API Pact test › getting all products › products exists

    TypeError: Cannot read property 'verify' of undefined

      19 |
      20 |     afterEach(async () => {
    > 21 |         await provider.verify();
         |                        ^
      22 |     });
      23 |
      24 |     afterAll(async () => {

      at Pact.verify (node_modules/@pact-foundation/src/httpPact.ts:113:8)
      at Object.afterEach (src/api.pact.spec.js:21:24)

  ● API Pact test › getting all products › no products exists

    Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

      at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

  ● API Pact test › getting all products › no products exists

    TypeError: Cannot read property 'addInteraction' of undefined

      66 |
      67 |             // set up Pact interactions
    > 68 |             await provider.addInteraction({
         |                            ^
      69 |                 state: 'no products exist',
      70 |                 uponReceiving: 'get all products',
      71 |                 withRequest: {

      at Pact.addInteraction (node_modules/@pact-foundation/src/httpPact.ts:102:29)
      at Object.test (src/api.pact.spec.js:68:28)

  ● API Pact test › getting all products › no products exists

    TypeError: Cannot read property 'verify' of undefined

      19 |
      20 |     afterEach(async () => {
    > 21 |         await provider.verify();
         |                        ^
      22 |     });
      23 |
      24 |     afterAll(async () => {

      at Pact.verify (node_modules/@pact-foundation/src/httpPact.ts:113:8)
      at Object.afterEach (src/api.pact.spec.js:21:24)

  ● API Pact test › getting all products › no auth token

    Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

      at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

  ● API Pact test › getting all products › no auth token

    TypeError: Cannot read property 'addInteraction' of undefined

       96 |
       97 |             // set up Pact interactions
    >  98 |             await provider.addInteraction({
          |                            ^
       99 |                 state: 'products exist',
      100 |                 uponReceiving: 'get all products with no auth token',
      101 |                 withRequest: {

      at Pact.addInteraction (node_modules/@pact-foundation/src/httpPact.ts:102:29)
      at Object.test (src/api.pact.spec.js:98:28)

  ● API Pact test › getting all products › no auth token

    TypeError: Cannot read property 'verify' of undefined

      19 |
      20 |     afterEach(async () => {
    > 21 |         await provider.verify();
         |                        ^
      22 |     });
      23 |
      24 |     afterAll(async () => {

      at Pact.verify (node_modules/@pact-foundation/src/httpPact.ts:113:8)
      at Object.afterEach (src/api.pact.spec.js:21:24)

  ● API Pact test › getting one product › ID 10 exists

    Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

      at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

  ● API Pact test › getting one product › ID 10 exists

    TypeError: Cannot read property 'addInteraction' of undefined

      119 |
      120 |             // set up Pact interactions
    > 121 |             await provider.addInteraction({
          |                            ^
      122 |                 state: 'product with ID 10 exists',
      123 |                 uponReceiving: 'get product with ID 10',
      124 |                 withRequest: {

      at Pact.addInteraction (node_modules/@pact-foundation/src/httpPact.ts:102:29)
      at Object.test (src/api.pact.spec.js:121:28)

  ● API Pact test › getting one product › ID 10 exists

    TypeError: Cannot read property 'verify' of undefined

      19 |
      20 |     afterEach(async () => {
    > 21 |         await provider.verify();
         |                        ^
      22 |     });
      23 |
      24 |     afterAll(async () => {

      at Pact.verify (node_modules/@pact-foundation/src/httpPact.ts:113:8)
      at Object.afterEach (src/api.pact.spec.js:21:24)

  ● API Pact test › getting one product › product does not exist

    Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

      at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

  ● API Pact test › getting one product › product does not exist

    TypeError: Cannot read property 'addInteraction' of undefined

      157 |
      158 |             // set up Pact interactions
    > 159 |             await provider.addInteraction({
          |                            ^
      160 |                 state: 'product with ID 11 does not exist',
      161 |                 uponReceiving: 'get product with ID 11',
      162 |                 withRequest: {

      at Pact.addInteraction (node_modules/@pact-foundation/src/httpPact.ts:102:29)
      at Object.test (src/api.pact.spec.js:159:28)

  ● API Pact test › getting one product › product does not exist

    TypeError: Cannot read property 'verify' of undefined

      19 |
      20 |     afterEach(async () => {
    > 21 |         await provider.verify();
         |                        ^
      22 |     });
      23 |
      24 |     afterAll(async () => {

      at Pact.verify (node_modules/@pact-foundation/src/httpPact.ts:113:8)
      at Object.afterEach (src/api.pact.spec.js:21:24)

  ● API Pact test › getting one product › no auth token

    Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.

      at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)

  ● API Pact test › getting one product › no auth token

    TypeError: Cannot read property 'addInteraction' of undefined

      181 |
      182 |             // set up Pact interactions
    > 183 |             await provider.addInteraction({
          |                            ^
      184 |                 state: 'product with ID 10 exists',
      185 |                 uponReceiving: 'get product by ID 10 with no auth token',
      186 |                 withRequest: {

      at Pact.addInteraction (node_modules/@pact-foundation/src/httpPact.ts:102:29)
      at Object.test (src/api.pact.spec.js:183:28)

  ● API Pact test › getting one product › no auth token

    TypeError: Cannot read property 'verify' of undefined

      19 |
      20 |     afterEach(async () => {
    > 21 |         await provider.verify();
         |                        ^
      22 |     });
      23 |
      24 |     afterAll(async () => {

      at Pact.verify (node_modules/@pact-foundation/src/httpPact.ts:113:8)
      at Object.afterEach (src/api.pact.spec.js:21:24)

Test Suites: 1 failed, 1 total
Tests:       6 failed, 6 total
Snapshots:   0 total
Time:        7.528s
Ran all test suites matching /pact.spec.js/i.
Jest did not exit one second after the test run has completed.
shilgam commented 4 years ago

Bumping jest timeout fixed the same issue for me.

Examples:

mefellows commented 3 years ago

Thanks, closing this as all steps now have an increased timeout.