Comments (2)
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.
Thanks man, you are super helpfull!
from postman-bdd.
Related Issues (17)
- Update version of Chai.js and is-ip HOT 3
- Postman collection not able to run using newman command line HOT 4
- BDD Library gives error on checking Content-Length header HOT 2
- Integration broken and Test cases not updated back due to Test link as assertion number "1. SP-3751:Get response 200" HOT 3
- How to stop the test case if the test fails. HOT 5
- Asserting header contents HOT 2
- Invalid Chai property: result HOT 2
- after, afterEach, before, beforeEach are not defined in Postman HOT 4
- Using latest Postman HOT 1
- Run postman BDD on newman HOT 2
- try to get postman-bdd got "Unexpected '/' " result HOT 4
- before hook inside describe is not load HOT 1
- False negatives HOT 2
- Create typescript definition for postman-bdd HOT 14
- Not much of an issue HOT 5
- Array assertion expects the returned JSON to be an Object. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from postman-bdd.