question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] How to run Polly Codeceptjs

See original GitHub issue

Hi all! I am trying to run codeceptjs (webdriverio) with polly, I am getting error with:

[Polly] [adapter:fetch] fetch global not found.

My code is:


const {
    Polly
} = require('@pollyjs/core');
 const FetchAdapter = require('@pollyjs/adapter-fetch')
 const XHRAdapter = require('@pollyjs/adapter-xhr')
 const RESTPersister = require('@pollyjs/persister-rest')
Polly.register(FetchAdapter);
Polly.register(XHRAdapter);
Polly.register(RESTPersister);

Before(async (I) => {
    // try {
        I.amOnPage("/");
         const polly = new Polly('Simple Example', {
             adapters: ['fetch'], // Hook into `fetch`
             persister: 'local-storage', // Read/write to/from local-storage
             logging: true // Log requests to console
         });
        await I.login();

I have one more question if I want to record the rest and change it like I want to change only one attribute in response how can I do it? If its not possible how I reuse the mocks ? where they will be saved ?

thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
jasonmitcommented, Jul 21, 2019

@vitaly87 that may likely do the trick. I cannot say for certain since I do not know the testing framework you’re using.

0reactions
vitaly87commented, Aug 9, 2019

Finally I get it working , I download the pollyjs via cdn and did polly.server . All of this was done from excude script from chrome. You can’t do it out of chrome scope .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Polly | CodeceptJS
Polly. Extends MockRequest. This helper works the same as MockRequest helper. It has been included for backwards compatibility reasons.
Read more >
Getting Started - CodeceptJS
Interactive shell started Press ENTER to resume test Use JavaScript syntax to try steps in action - Press ENTER to run the next...
Read more >
Releases - CodeceptJS
Use it to perform run multiple times and detect flaky tests ... use Polly & Puppeteer helpers I.mockRequest('GET', '/api/users', 200); I.mockRequest('POST', ...
Read more >
Quickstart - CodeceptJS
To start a new project initialize CodeceptJS to create main config file: codecept.conf.js . npx codeceptjs init. Answer questions, agree on defaults: ...
Read more >
Testing with Puppeteer - CodeceptJS
If you already have CodeceptJS project, just install puppeteer package and enable a helper it in config. ... You will be asked for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found