Create-react-app: what's `it` mean?

Created on 25 Mar 2017  路  3Comments  路  Source: facebook/create-react-app

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 of it if you'd like.

All 3 comments

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);
  });
});
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ericvicenti picture ericvicenti  路  83Comments

gaearon picture gaearon  路  85Comments

sgriffey picture sgriffey  路  113Comments

jantimon picture jantimon  路  154Comments

daviseford picture daviseford  路  108Comments