What I am trying to do
The program I'm following has me working on test driven development in JavaScript. It wants all the tests to complete at the same time. But my problem is that they're all required to be under the same function name sumAll. When two or more functions have the same name, this throws an error.
How do I run all tests at once without throwing an error? I can pass all the tests individually by deleting .skip off the next one and adding .skip to the previous one.
Here are the tests I am trying to run.
const sumAll = require('./sumAll')
describe('sumAll', () => {
test('sums numbers within the range', () => {
expect(sumAll(1, 4)).toEqual(10);
});
test.skip('works with large numbers', () => {
expect(sumAll(1, 4000)).toEqual(8002000);
});
test.skip('works with larger number first', () => {
expect(sumAll(123, 1)).toEqual(7626);
});
test.skip('returns ERROR with negative numbers', () => {
expect(sumAll(-10, 4)).toEqual('ERROR');
});
test.skip('returns ERROR with non-number parameters', () => {
expect(sumAll(10, "90")).toEqual('ERROR');
});
test.skip('returns ERROR with non-number parameters', () => {
expect(sumAll(10, [90, 1])).toEqual('ERROR');
});
});
Via Active questions tagged javascript - Stack Overflow https://ift.tt/X5LfCGH
Comments
Post a Comment