pollyjs icon indicating copy to clipboard operation
pollyjs copied to clipboard

BUG -- Concurrency error with node-http adapter when running a test suite with skipped test

Open AELSchauer opened this issue 3 years ago • 3 comments

Description

Running a test suite with any skipped tests with jest (xit, it.only, it.skip) results in a concurrency error. However, running the same set of tests in which no tests are skipped, does not result in any errors.

Shareable Source

it('test A', async () => {
  ...
});

xit('test B', async () => {
  ...
});

Error Message & Stack Trace

PollyError: [Polly] [adapter:node-http] Running concurrent node-http adapters is unsupported, stop any running Polly instances.

      at Object.assert (node_modules/@pollyjs/utils/src/utils/assert.js:5:11)
      at HttpAdapter.assert (node_modules/@pollyjs/adapter/src/index.js:224:5)
      at HttpAdapter.onConnect (node_modules/@pollyjs/adapter-node-http/src/index.js:39:10)
      at HttpAdapter.connect (node_modules/@pollyjs/adapter/src/index.js:48:12)
      at Polly.connectTo (node_modules/@pollyjs/core/src/polly.js:281:13)
      at forEach (node_modules/@pollyjs/core/src/polly.js:165:50)
          at Array.forEach (<anonymous>)
      at Polly.configure (node_modules/@pollyjs/core/src/polly.js:165:26)
      at new Polly (node_modules/@pollyjs/core/src/polly.js:49:10)
      at PollyEnvironmentNode.handleTestEvent (node_modules/setup-polly-jest/lib/jest-environment-polly.js:85:48)

Config

Copy the config used to setup the Polly instance:

setupPolly({
  adapters: [NodeHttpAdapter],
  persister: FSPersister,
  persisterOptions: {
    fs: {
      recordingsDir: path.resolve(__dirname, '__recordings__')
    }
  }
});

Dependencies

Copy the @pollyjs dependencies from package.json:

{
    "@pollyjs/adapter-node-http": "^5.0.0",
    "@pollyjs/core": "^5.0.0",
    "@pollyjs/persister-fs": "^5.0.0",
    "jest": "^26.4.2",
    "jest-circus": "^26.4.2",
    "setup-polly-jest": "^0.9.1",
}

Environment

Server-side tests. Node v12.18.3 darwin 17.7.0 npm v6.14.6

AELSchauer avatar Sep 01 '20 19:09 AELSchauer

Thanks for all the info, we'll look into it.

jasonmit avatar Sep 05 '20 03:09 jasonmit

@gribnoysup I wonder if this is an issue caused by the jasmine setup done in setup-polly-jest? Have you run into this sort of issue before?

offirgolan avatar Sep 07 '20 02:09 offirgolan

Hmmm... we have a test case for it.only and I just added one for it.skip and both are passing on jest with jasmine2 and with circus runner. It might be something with the setup-polly-jest helper especially as jest-circus support is pretty new and I don't think a lot of people are using it, but it would be really hard to tell without a reproduction. Maybe you can provide a more complete example @AELSchauer?

gribnoysup avatar Sep 07 '20 09:09 gribnoysup