Over the weekend I wrote a small node library for smoke web tests called advanced-smoke and published my first public VSTS extension for it.
The source for both is available on github: node-advanced-smoke vsts-advanced-smoke. Both are written in TypeScript.
advanced-smoke for the cli
> npm i -g advanced-smoke
> advanced-smoke.cmd https://google.com https://google.de
[Advanced Smoke]: initialize smoke test
[Advanced Smoke]: testing url https://google.com
[Advanced Smoke]: SUCCESS: received status code 200, expected 200
[Advanced Smoke]: testing url https://google.de
[Advanced Smoke]: SUCCESS: received status code 200, expected 200
inline help
> advanced-smoke --help
Usage: advanced-smoke.js <url> [<url2> <url3> ...] [options]
Options:
--version Show version number [boolean]
--status, -s HTTP status to validate [number] [default: 200]
--method, -m HTTP method [string] [default: "GET"]
--headers Headers to send
Use --headers.name value [array]
--timeout, -t Timeout [number]
--resolveWithFullResponse Full request or just head [boolean] [default: true]
--noExitCode, --ne Doesn't exit the process [boolean] [default: false]
--strictSSL Whether SSL certificates are required to be valid
[boolean] [default: true]
--proxy, -p Proxy server to use for the request.
HTTP(S)_PROXY, NO_PROXY and ADVANCED_SMOKE_PROXY
environment variables are also supported [string]
-h, --help Show help [boolean]
advanced-smoke for node
Here is a simple example how to use the library in node.
Install
yarn add advanced-smoke
or
npm i --save advanced-smoke
Usage in TypeScript
import * as smoke from "advanced-smoke";
async function run()
{
const res = await smoke.smokeTest({
url: "https://google.com,
status: 200,
method: "GET,
resolveWithFullResponse: true
};
console.log(res ? "success" : "fail");
}
run();
advanced-smoke for VSTS
with multiple urls
every option available under the Advanced tab
additional feature: retry
The VSTS task offers the option for retries (with configurable delay), so you can account for warm up times if used directly after deployment. The task should only fail if even the last retry has failed smoke tests.
that was my coding weekend
I hope anyone will find this useful. I would love to hear from you if you try it, ping me on twitter @petersendev. I will also happily accept pull request on github.
No comment