Starter project creado en vivo en Stream de Twitch basado en Postman, Newman, NodeJS y TypeScript
-
Instalar Node.js
-
Instalar algún cliente git como por ejemplo git bash
-
Instalar Newman de manera global.
npm install -g newman
git clone https://github.com/charlyautomatiza/starter-postman-newman.git
npm install
npm run test
cd newman
ls
Para ejecutar con tus propias collections basta con modificar el require en el archivo main.ts de la opción "collection"
// Runner collection local
newman.run({
collection: require('./collections/yourCollectionName.json'),
reporters: reporters,
}, function (err: Error | null) {
if (err) { throw err; }
console.log('Collection run complete!');
});
// Runner collection Cloud
newman.run({
collection: 'https://www.getpostman.com/collections/YourCollectionID',
reporters: reporters,
}, function (err: Error | null) {
if (err) { throw err; }
console.log('Cloud collection run complete!');
});
Para agregar o quitar tipos de reportes basta con modificar la constante reports del archivo main.ts de la opción "collection"
// List of reports
const reports = ['junit', 'cli', 'progress', 'json'];
Para poder ejecutar las collections desde la nube debes tener una cuenta de Postman.
Deberás exportar tu collection en la nube y obtener el ID de la collection mediante.
- Seleccionar la opción "Share".
- Seleccionar "Vía JSON link".