Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ttwiesal committed Mar 20, 2024
1 parent 0729126 commit b0b270f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions index.spec.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
describe('postman-runner', () => {
const consoleErrorSpy = jest.spyOn(console, 'error');
const chalk = require('chalk');
beforeEach(() => {
jest.resetModules();
process.argv = ['', ''];
});

it('should fail when no path to collection was provided.', () => {
require('./index.js');
expect(consoleErrorSpy).toHaveBeenCalledWith('No path to collection provided! Use --collection');
expect(consoleErrorSpy).toHaveBeenCalledWith(chalk.bold.bgRed('No path to collection provided! Use --collection'));
});

it('should fail when runCount is 0.', () => {
process.argv = ['test', '--collection="./sample-collections/TSTcloud.postman_collection.json"', '--runCount=0'];
require('./index.js');
expect(consoleErrorSpy).toHaveBeenCalledWith('Provided runCount is less or equal than 0!');
expect(consoleErrorSpy).toHaveBeenCalledWith(chalk.bold.bgRed('Provided runCount is less or equal than 0!'));
});

it('should fail when runCount is not an integer.', () => {
process.argv = ['test', '--collection="./sample-collections/TSTcloud.postman_collection.json"', '--runCount=asdf'];
require('./index.js');
expect(consoleErrorSpy).toHaveBeenCalledWith('The runCount is not an integer!');
expect(consoleErrorSpy).toHaveBeenCalledWith(chalk.bold.bgRed('The runCount is not an integer!'));
});

it('should run collection 10 times when no runcount is provided.', () => {
Expand Down Expand Up @@ -65,7 +66,7 @@ describe('postman-runner', () => {

require('./index.js');

expect(consoleErrorSpy).toHaveBeenCalledWith('Error: Testerror');
expect(consoleErrorSpy).toHaveBeenCalledWith(chalk.bold.bgRed('Error: Testerror'));
});

afterEach(() => {
Expand Down

0 comments on commit b0b270f

Please sign in to comment.