This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('is OK - not bad', async () => { | |
let result = await testFunction(true) | |
expect(result).to.be.equal('OK') | |
// flawed test throws an error, but it is not a test error (AssertionError) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('is not OK - not bad, but it could be better', async () => { | |
try { | |
let result = await testFunction(false) | |
expect.fail() | |
// flawed test throws an ugly error: | |
} catch (err) { | |
// ...'AssertionError: expected 'expect.fail()' to equal 'not OK'' | |
expect(err.message).to.be.equal('not OK') | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('is not OK - bad!', async () => { | |
try { | |
let result = await testFunction(false) | |
// flawed tests __pass__ instead of throws an error! | |
} catch (err) { | |
expect(err.message).to.be.equal('not OK') | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function testFunction (isOK) { | |
if (isOK === true) { | |
return 'OK' | |
} else { | |
throw new Error('not OK') | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('is not OK - better way', async function() { | |
let result, error | |
try { | |
result = await testFunction(false) | |
} catch (err) { | |
error = err | |
} finally { | |
expect(result).to.be.undefined() // guard: handling code flaw | |
expect(error.message).to.be.equal('not OK') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('is OK - better way', async function() { | |
let result, error | |
try { | |
result = await testFunction(true) | |
} catch (err) { | |
error = err | |
} finally { | |
expect(error).to.be.undefined() // guard: handling code flaw | |
expect(result).to.be.equal('OK') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('your test', async function() { | |
let args = ... // your test data | |
let result, error // variables: test and guard in the finally block | |
try { | |
result = await testFunction(args) | |
} catch (err) { | |
error = err | |
} finally { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Selenium WebDriver JavaScript test with Mocha and NodeJS | |
* | |
* Start with: SELENIUM=PATH_TO_SELENIUM_JAR/selenium-server-standalone-2.31.0.jar mocha -t 10000 -R list google-sample.js | |
* | |
* Download selenium-server-standalone-2.31.0.jar from https://selenium.googlecode.com/files/selenium-server-standalone-2.31.0.jar | |
* 'sudo su' and 'npm install -g colors mocha selenium-webdriver' | |
* | |
* http://visionmedia.github.io/mocha/ | |
* https://code.google.com/p/selenium/wiki/WebDriverJs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:8-alpine | |
# the client version we will download from bumpx repo | |
ENV CLIENT_FILENAME instantclient-basic-linux.x64-12.1.0.1.0.zip | |
# work in this directory | |
WORKDIR /opt/oracle/lib | |
# take advantage of this repo to easily download the client (use it at your own risk) | |
ADD https://github.com/bumpx/oracle-instantclient/raw/master/${CLIENT_FILENAME} . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const ITERATION = 1000 | |
console.log( | |
process.version, | |
ITERATION, | |
'iteration', | |
'with Type and freeze – v2: prototype based constructor function' | |
) |