Giter Club home page Giter Club logo

Comments (2)

JamesMessinger avatar JamesMessinger commented on August 16, 2024 3

Hi. I don't want to start adding Chai plugins to PostmanBDD, since it will bloat PostmanBDD with extra stuff that most people don't need. But you can easily add the Chai-Subset plugin (or any other Chai plugin) yourself.

1. Download the file
Any JavaScript file that's hosted anywhere online (such as GitHub) can be loaded in Postman by simply adding a GET request to download the JavaScript file, exactly the same way that you downloaded PostmanBDD. For example, to download Chai-Subset, you'd just need to add a GET request with the following URL:

https://cdn.rawgit.com/debitoor/chai-subset/96755808/lib/chai-subset.js

2. Store the script in a variable
Once the JavaScript file has been downloaded, you need to store it in a variable so you can access it from other Postman requests. Again, this is exactly the same as when you "installed" PostmanBDD. So, to store Chai-Subset in a variable, you'd do something like this:

postman.setGlobalVariable('chaiSubset', responseBody);

3. Load the script whenever it's needed
Once you've stored the script in a variable, it's available to use wherever you need it. You can "load" the script in any request by using the JavaScript eval() function, just like you did when you loaded PostmanBDD. So, to load Chai-Subset, you'd just do this:

// Load PostmanBDD first, since it includes Chai.js
eval(globals.postmanBDD);

// Load Chai-Subset next, since it depends on Chai.js
eval(globals.chaiSubset);

// Now you can use PostmanBDD and Chai-Subset
describe('My test suite', () => {

  it('should return the expected JSON data', () => {
    response.body.should.containSubset({
      firstName: 'John',
      lastName: 'Doe',
    });
  });

});

from postman-bdd.

leozilla avatar leozilla commented on August 16, 2024

Thanks man, you are super helpfull!

from postman-bdd.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.