DEV Community

Discussion on: What are the great function/method/etc. names in popular libs/languages?

Collapse
 
itsasine profile image
ItsASine (Kayla)

Testing frameworks are fun for this because by nature of what the code does, it ends up being a source of truth for how the app behaves. Thus, the test specs can kind of read like documentation.

Assuming var thing = 10;

Some Jasmine:

expect(thing).toBeTruthy();

expect(thing).not.toBeLessThan(5);

expect(thing).toBeGreaterThanOrEqualTo(5);

expect(thing).toEqual(10);

expect(new Promise(thing)).toEqual(10);

Some Mocha with Chai:

thing.should.be.a('number');

thing.should.equal(10);

expect(thing).to.equal(10);

expect(new Promise(thing)).to.eventually.equal(10);

I also just like the punny names of testing languages, to be honest.

Collapse
 
ben profile image
Ben Halpern

Yeah, I find this especially true in Ruby, where whitespace rules can make things almost plain english (though some take this way to far. It's a balance)