2.0” gave a lot of attention to the frontend • lots of responsive UI and SPA • tighter release cycles • tools and frameworks are grown and become mature
testing method by which individual units of source code, sets of one or more computer program modules together with associated control data, usage procedures, and operating procedures, are tested to determine whether they are fit for use.” source: https://en.wikipedia.org/wiki/Unit_testing
developed by Pivotal Labs (https://en.wikipedia.org/wiki/JSUnit) • QUnit (~2006) initially developed by John Resig as a part of jQuery, used to test jQuery, jQuery UI and jQuery Mobile (http://qunitjs.com/) • Jasmine (2010) developed by Pivotal Labs (http://jasmine.github.io/) • Mocha (2011) initially developed by TJ Holowaychuk (http://mochajs.org/)
(2011) developed by TapJS (https://github.com/tapjs/node-tap) • tape (2012) developed by James Halliday (substack) (https://github.com/substack/tape) • AVA (2014) developed by Sindre Sorhus (https://github.com/sindresorhus/ava/) More information about Test Anything Protocol (TAP) (https://en.wikipedia.org/wiki/Test_Anything_Protocol)
GET https://api.github.com/users/{username}/repos • to get user’s specific repository info: GET https://api.github.com/repos/{username}/{reponame} • more info at https://developer.github.com/v3/
rate limit allows you to make up to 60 requests per hour (https://developer.github.com/v3/#rate-limiting) • you can cache the response and use ETag or Last-Modified returned values in a subsequent request passing If-None-Match or If-Modified-Since in the header, getting a 304 if the response is not modified; a 304 response does not count against rate limit (https://developer.github.com/v3/#conditional-requests)
with globals • sharing the same variable between tests must be passed in a test context • babel-plugin-rewire must be applied to source files • shallow rendering does not yet support refs
export function getUserReposListURL(username) { if (!username) { throw new Error('Username is undefined, null or an empty string'); } return `${githubBaseURL}/users/${encodeURIComponent(username)}/repos`; }; src/github.js
test('should generate the list of repositories url', t => { t.is(github.getUserReposListURL('maur8ino'), 'https://api.github.com/users/maur8ino/repos'); t.is(github.getUserReposListURL('maur/8i&no'), 'https://api.github.com/users/maur%2F8i%26no/repos'); }); test/github-test.js
testing conducted on a complete, integrated system to evaluate the system's compliance with its specified requirements. System testing [End-to-end] falls within the scope of black box testing, and as such, should require no knowledge of the inner design of the code or logic.” source: https://en.wikipedia.org/wiki/System_testing
Huggins in 2004 • automate web browsers across many platforms • de-facto standard for testing end-to-end web applications • Selenium Webdriver, maybe the main reason why Selenium is popular, accepts command in “Selenese” and communicates with real browser • Selenium IDE has a Firefox addon to record, edit and playback browser interaction • Selenium Grid acts as a hub for Webdriver instances http://docs.seleniumhq.org/
feature • can have a Background list of steps to do for every Scenario • has one or more Scenarios • every step of Background and Scenarios starts with Given, When, Then, But or And keywords; there is no actual difference between them, they let you describe even better the feature
file can be resolved by one step definition (because of regular expression) • lets you use all the power of the language • drives real browser via selenium or headless browser like zombiejs or phantomjs
webdriver • feature files will be placed in features/ • step definition files will be placed in features/steps • support files will placed in features/support
that program testing may convincingly demonstrate the presence of bugs, but can never demonstrate their absence. After quoting this well-publicized remark devoutly, the software engineer returns to the order of the day and continues to refine his testing strategies, just like the alchemist of yore, who continued to refine his chrysocosmic purifications.” (E. W. Dijkstra, 1988) source: https://www.cs.utexas.edu/~EWD/transcriptions/EWD10xx/EWD1036.html Quote of the day: