import sum from './sum';
it('sums numbers', () => {
expect(sum(1, 2)).toEqual(3);
expect(sum(2, 2)).toEqual(4);
});
https://github.com/facebook/jest
https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#writing-tests
https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#testing-components
Don't ask here please.
Read about it
at right place.
It is just helper which allows less tech people read test case. It is a context for (jest
, computer) language.
Techically, it
is just an object which let you define your expectations in tests
Asking here is fine, we don't mind answering! We love questions so please don't feel bad about asking us.
That said the answer above is correct. It is a function that defines a test. The name comes from a similar approach in Ruby libraries (I think?) and aims to create an English sentence with the test title (e.g. "it works" or "it should do something").
You can write test
instead of it
if you'd like.
Yeah, you are right!
Most of JavaScript test framework using it
as the assertion !
https://mochajs.org/#getting-started
var assert = require('assert');
describe('Array', function() {
describe('#indexOf()', function() {
it('should return -1 when the value is not present', function() {
assert.equal(-1, [1,2,3].indexOf(4));
});
});
});
https://jasmine.github.io/
https://jasmine.github.io/edge/node.html
describe("A suite is just a function", function() {
var a;
it("and so is a spec", function() {
a = true;
expect(a).toBe(true);
});
});
Most helpful comment
Asking here is fine, we don't mind answering! We love questions so please don't feel bad about asking us.
That said the answer above is correct. It is a function that defines a test. The name comes from a similar approach in Ruby libraries (I think?) and aims to create an English sentence with the test title (e.g. "it works" or "it should do something").
You can write
test
instead ofit
if you'd like.