Unexpected
The extensible assertion library
Started in 2013 as an experiment.
Used by One.com from v1.0.4
and is used for all JavaScript testing now.
Unexpected is starting to be used by other companies.
A small but very active and helpful community.
Find Gitter and Github links on http://unexpected.js.org.
We have great documentation!
Many plugins that cover most functionality.
Syntax matters
programs_should_be_written_for_people_to_read_and_only_incidentally_for_machines_to_execute
programs.should.be.written.for.people.to.read.and.only.incidentally.for.machines.to.execute
programsShouldBeWrittenForPeopleToReadAndOnlyIncidentallyForMachinesToExecute
Programs should be written for people to read, and only incidentally for machines to execute.
— Abelson and Sussman
Assertions are just text - feel free to express yourself.
Especially important when you are doing complicated stuff:
A nice side-effect of using strings:
Context is important
Being precise makes a difference
We even diff buffers:
Generally we try to be as helpful as possible:
Invalidates best practices
There should only be one assertion per test!
A single assert per unit test is a great way to test the reader's ability to scroll up and down.
A test should be concise and readable.
Match your object hierarchy against a specification:
The world is not sequential
Asynchronous assertions:
...and they compose:
Extensible from the ground up
Adding assertions
Adding types
Almost anything is possible
Create plugins that extends unexpected with new types, assertions, styles and themes.
unexpected-sinon
Testing with fakes
Questions
The end
Stickers for everybody :-)