- ๐ซ @t2ym's OpenPGP public key for
[email protected]
is available at t2ym/thin-hook#407
t2ym / scenarist Goto Github PK
View Code? Open in Web Editor NEWClass-based branching test scenario runner for mocha
License: Other
Class-based branching test scenario runner for mocha
License: Other
[email protected]
is available at t2ym/thin-hook#407With Safari, the demo animation GIF (scenaristdemo.gif
) on README is not shown
With Edge 13/14, and Safari 7/8/9/10, tests with istanbul hang up on 400 "Bad Request", although tests themselves on browsers succeed.
Perform tests without istanbul
Experimental support of native ES6 modules with Safari Technical Preview Release 21
test/module/Suite.js
has the same content as Suite.mjs
polyserve
does not support the .mjs
extension as a script typebower_components/stacky/browser.js
needs this patch at line#45 since global
is definedvar isNode = new Function('try {return this===global && window!==global;}catch(e){return false;}');
Convert underscores into spaces in uncamel()
[Polymer 2.x][app-location] Query parameters for HTML suites disappear
iron-location
in app-location
cannot handle query parameters properly with Polymer 2.x
@t2ym/web-component-tester
(bower: t2ym/web-component-tester
) with #hashtag support in html suitesAdd optional exception handler method
reject()
, it must return non-null to tell the runner not to call resolve()
class ExampleTest3 extends ExampleSuite {
async operation() { ... }
async checkpoint() { ... }
exception(reject, exception) {
// default action when exception() is not defined
reject(exception);
return true;
}
}
try {
await (new ExampleTest3('#example')).run();
}
catch (exception) {
// Handle exception in runner
...
}
class ExampleTest4 extends ExampleSuite {
async operation() { ... }
async checkpoint() { ... }
exception(reject, exception) {
// Treat the exception as a test failure by mocha
test('exception on scenario', function() {
throw exception;
});
}
}
With Suite.js
using native async/await
, istanbul
cannot generate coverage reports.
The current version of JS parser esprima
, on which istanbul
depends, cannot properly parse async/await
syntax.
npm install istanbul-espree
node_modules/istanbul-espree/lib/instrumentor.js
in istanbul-espree
with ecmaVersion: 8
from ecmaVersion: 7
in ESP.parse()
nvm use 7
node --harmony ./node_modules/istanbul-espree/lib/cli.js cover ./node_modules/mocha/bin/_mocha test/src/test.js --report lcov -- -R spec
node_modules/web-component-tester-istanbul/node_modules/istanbul-espree
istanbul-espree
folder as istanbul
async/await
-ready browser like Chrome 55+On Egde and IE11, exception()
handler is not called
Add explicit error handling for invalid identifiers
Class name with the same name as the corresponding mixin name can be defined only once with the last mixin in the chain as the corresponding mixin.
Class name with the same name as an existing mixin name is not allowed unless the above condition is met.
error.test = (base) => class DefinedMixinBase3 extends base {}
error.test = (base) => class DefinedMixinBase4 extends base {}
error.test = (base) => class DefinedMixinBase5 extends base {}
error.test = {
DummyTest: {
DefinedMixinBase3: 'DefinedMixinBase3' // no error
}
};
error.test = {
DummyTest: {
DefinedMixinBase5: '' // no error; defaults to 'DefinedMixinBase5'; allowed only once
}
};
error.test = {
DummyTest: {
DefinedMixinBase3: 'DefinedMixinBase4' // error
}
};
Mixin name with another existing class name is not allowed.
error.test = class DefinedClass1 extends Suite {}
error.test = (base) => class DefinedMixinBase6 extends base {}
error.test = (base) => class DefinedMixinBase7 extends base {}
error.test = {
'': {
DefinedMixinBase6: {
DefinedMixinBase7: 'DefinedClass1' // error
}
}
};
Unable to catch multiple exceptions/rejections from testInstance.run()
on Suite.scopes[scope].run()
Promise.all([ testInstance.run(), ... ]).catch()
in run()
can catch only the first exception.
for (var scope in Suite.scopes) {
Suite.scopes[scope].test.forEach(function (tests, index) {
Suite.scopes[scope].run(index)
.catch(e => { /* Only the first exception in each run() can be caught */ });
});
}
async function runner() {
for (let scope in Suite.scopes) {
for (let index in Suite.scopes[scope].test) {
try {
await Suite.scopes[scope].run(index);
}
catch (e) {
/* Only the first exception in each run() can be caught */
}
}
}
}()
On Edge 15.14986 with Suite.js
, "Class constructor cannot be called without the new keyword" error is thrown on subclassing. This should be a bug for Edge 15 prerelease build 14986.
let example = Suite('example');
example.test = class ExampleSuite extends Suite {}
let example = Suite('example');
let t;
example.test = t = class ExampleSuite extends Suite {}
Compatibility with NodeJS.
async/await
with the flag --harmony_async_await
Suite.min.js
and test classes with the help of babel-polyfill
On GitHub pages, demo's path/index.html
are responded with 404 Not Found.
Use the corresponding URL path/
instead.
Support module context, i.e., non-global Suite
class
// test.js
let assert = require('chai').assert;
let Suite = require('scenarist/Suite.min.js');
require('./scope1.js')(Suite, assert);
require('./scope2.js')(Suite, assert);
for (let scope in Suite.scopes) {
Suite.scopes[scope].test.forEach(function (tests, index) {
Suite.scopes[scope].run(index);
});
}
// scope1.js
module.exports = function (Suite, assert) {
let scope1 = new Suite('scope1');
scope1.test = ...
return scope1; // optional since scope1 === Suite.scopes.scope1
}
On Edge 15.14986 with raw Suite.js
, no class mixin name test fails.
no class mixin name
โฃ
Error: expected [Function] to throw an error
AssertionError at /components/chai/chai.js:5553
Assertion.prototype.assert at /components/chai/chai.js:206
assertThrows at /components/chai/chai.js:1665
ctx[name] at /components/chai/chai.js:4192
assert.throws at /components/chai/chai.js:3271
Anonymous function at error.js:43
assert.throws(function () {
error.test = (base) => class extends base {}
}, /Suite[.]error: class mixin has no name /);
Polymer.dom()
is hard-coded in forEvent()
forEvent()
should be applicable to general use without Polymer.
Since Suite.min.js
is still using dynamically generated ES6 class syntax, IE11 cannot execute the test classes.
new Function('return class ...')
has to be converted to ES5 classes
Leaf test class which has the same name as its corresponding mixin can unexpectedly be trimmed even if it has a unique scenario.
In transpiled Suite.min.js
, anonymous class has an invalid name _class
.
SuiteObjectInstance.arrowFunctionSupport
is always false due to the incorrect condition
Support subscopes of scopes
Suite <-- GlobalScope <-- ScopeA <-- SubscopeAB ...
+- SubscopeAC ...
Support bdd ui for mocha on Node.js to omit -u tdd
option
mocha test.js
or
mocha -u bdd test.js
In the scenario tree, word '0' occurrences are not shown. This should be a bug of Google Chart for the string '0'.
In addition to a number string and csv test names, support a number in the first argument of run()
run('10')
fails.
With Suite.min.js
, the following error is thrown.
TypeError: Class constructor cannot be invoked without 'new'
let scope = new Suite('scope');
scope.classSyntaxSupport = false;
Suppress debug console.log()
unless Suite.debug
is true
Add Suite.esm.js
for ES module version in .js
extension
Suite.mjs
to Suite.esm.js
Generate ES5 class without hard-coding Babel-transpiled codes
Update API Documentation
With native ES6 Suite.js
, show test class definitions on HTML reporter by overriding toString()
of test functions.
When is "the future"? How can the rejection be handled?
Test iteration error test
โ iteration generator error
(node:28970) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: iteration error
(node:28970) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Test scenario error test
โ scenario generator error
(node:28970) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): Error: scenario error
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.