Tasty helps to test fully assembled web applications in near-production environments on real web clients by emulating real users.
npm install -g tasty
Tasty supports both multiple and single page applications (with server rendering too) and code coverage. It respects Content Security Policy and SSL/TLS.
Tasty server controls connected web clients to run your tests in runner of your choice against your application.
Client can emulate real user: navigate, fill forms, check page contents.
- Add
tasty.js
module to your assembly or markup. - Assemble and serve your application from staging server.
- Provide CSP directives for Tasty and use test certificates, if needed.
- Write tests for your preferred test framework using Tasty async tools.
- Run Tasty server. Open application in any of your clients.
- For each client Tasty will run your tests and return all output.
- Edit tests, Tasty will re-run them automatically, if needed.
Is Selenium server required?
No. Tasty client is intended to run inside browser environment without WebDriver.
But you'll probably need Selenium-driven clients or tools like PhantomJS, Puppeteer and SlimerJS for automation.
The main purposes are:
- Emulate real user experience.
- Support any web client without WebDriver.
- Keep test scripts as simple as possible.
Tasty gives you only high-level tools to help treat your application as a black box, just like real user does. Interact with text and graphics, not with heartless HTML elements. Try not to use knowledge of your application's markup, assume you're helping a real person to achieve some goals.
Protractor and WebdriverIO are Selenium-based end-to-end test frameworks useful for intergration testing. Also take a look at Appium, CasperJS and Selendroid.
Karma and Testee are great tools for cross-browser unit testing.
Serve your application.
<html>
<head>
...
<script src="//localhost:8765/tasty.js"></script>
</head>
<body>
<form action="/dashboard">
Welcome!
<input placeholder="Username" type="text" />
<input placeholder="Password" type="password" />
<input value="Log in" type="submit" />
</form>
</body>
</html>
Write a test (this one uses Mocha).
describe('login form', function() {
it('logs user in', function() {
is(text('Welcome!'));
click(text('Username'));
type(tasty.config.username);
click(text('Password'));
type(tasty.config.password);
click(text('Log in'));
is(location('/dashboard'));
return now();
});
});
Run Tasty server.
tasty test.js --runner mocha --username 'John Doe' --password 'secret!'
Open your application in your client. Tasty will run the test, print all output and exit.
npm run prepublish
npm test
Main tests use SlimerJS and PhantomJS. SlimerJS itself requires Firefox to be installed. PhantomJS suite requires phantomjs
to be available via command prompt.
Because of tests for obsolete AppCache manifest, PhantomJS could put HTML page into persistent cache and then ignore clearMemoryCache
API calls. This may require to delete cache files manually from the following locations:
%HOMEDRIVE%%HOMEPATH%\AppData\Local\Ofi Labs\PhantomJS
~/Library/Caches/Ofi Labs/PhantomJS
~/.local/share/Ofi Labs/PhantomJS/
npm run support
Real-browser support tests are made possible by SauceLabs. Automation requires SAUCE_USERNAME
and SAUCE_ACCESS_KEY
environment variables,
which are kindly provided by TravisCI.
Everything works fine, yay!