-
Notifications
You must be signed in to change notification settings - Fork 672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some of QUnit tests should be replaced with functional tests #52
Comments
After the research we have an interface that we are going to implement for functional tests running. /cc @inikulin Is it all ok? |
@georgiy-abbasov Yay, looks like a long reading. I'll review on Monday if you wouldn't mind? Need a clear head for this. |
@georgiy-abbasov Can you ping me then, please? |
@inikulin, ok, we will discuss it together on Monday. |
@georgiy-abbasov Please write here the comments where we describe the interface you've written about. Don't force guys to look at our working long issue. Put the main things to this issue |
testcafe-functional-harnessAllows to run functional tests in local browsers or on SauceLabs. What it's doing
Install:
Usage:functionalHarness
.src(...sources)
.sitePorts(port1, port2)
.browsers(...{alias, url, name, platform}) //name and platform - for saucelabs
//optional
.saucelabs(username, accessKey, jobName)
.timeout(sec) //by default 180s
//run tests
.run(); |
TestCafeGulpfile.jsvar functionalHarness = require('test/functional/harness.js');
var FUNCTIONAL_TESTS_SETTINGS = {
testCafePort1: 2000,
testCafePort2: 2001,
sitePort1: 3000,
sitePort2: 3001
};
var FUNCTIONAL_TESTS_BROWSERS = {
platform: 'Windows 10',
browserName: 'microsoftedge',
alias: 'edge'
};
var SAUCELABS_FUNCTIONAL_SETTINGS = {
username: process.env.SAUCE_USERNAME,
accessKey: process.env.SAUCE_ACCESS_KEY,
build: process.env.TRAVIS_JOB_ID || '',
tags: [process.env.TRAVIS_BRANCH || 'master']
name: 'testcafe functional tests'
};
gulp.task('test-functional', function () {
var testsTimeout = 180;
return gulp
.src('test/functional/fixtures/**/*-test.js')
.pipe(functionalHarness.run(FUNCTIONAL_TESTS_SETTINGS, FUNCTIONAL_TESTS_BROWSERS,
testsTimeout, SAUCELABS_FUNCTIONAL_SETTINGS));
}); test/functional/harness.jsWhat it's doing:
test/functional/test-runner.jsWhat it's doing:
{
testName1: 'test1Error',
testName2: 'test2Error'...
} How it works:var harness = require(test/functional/harness.js);
var testCafe = harness.testCafe;
var browserInfo = harness.browserInfo;
export runTests(fixture, testName) {
var tc = harness.testCafe;
var runner = tc.createRunner();
return runner
.filter(function(){
...
})
.src(fixture)
.browsers(browserInfo)
.run()
.then(function()
{
// modify testcafe report to the following way:
//<testName>: [testError]
// throwing report if there was errors
});
} test/function/fixtures/
mocha test examplevar runTests = require('../../../../test-runner.js').runTests;
var expect = require('chai').expect;
describe('api click test', function () {
it('Should fail when the first argument is invisible', function () {
return runTests('./click.test.js', 'Should fail when the first argument is invisible')
.then(function () {
throw new Error('Test should fail but was succeed');
})
.catch(function (err) {
var expectedError = [
'Error at step "1.Click on invisible element":',
'',
'act.click($input);',
'',
'A target element \<input id="input"\> of the click action is not visible.',
'If this element should appear when you are hovering over another',
'element, make sure that you properly recorded the hover action.'
].join(' ');
expect(err['Should fail when the first argument is invisible']).eql(expectedError);
});
});
it('Pointer events test (T191183) [ONLY:ie]', function () {
return runTests('./click.test.js', 'Pointer events test (T191183) [ONLY:ie]')
.catch(function (err) {
expect(err['Pointer events test (T191183) [ONLY:ie]']).eql('');
});
});
}); |
it('Should fail when the first argument is invisible', function () {
return runTests('./click.test.js', 'Should fail when the first argument is invisible')
.then(function () {
throw new Error('Test should fail but was succeed');
})
.catch(function (err) {
var expectedError = [
'Error at step "1.Click on invisible element":',
'',
'act.click($input);',
'',
'A target element \<input id="input"\> of the click action is not visible.',
'If this element should appear when you are hovering over another',
'element, make sure that you properly recorded the hover action.'
].join(' ');
expect(err['Should fail when the first argument is invisible']).eql(expectedError);
});
}); BTW, maybe we can get rid of this part: .then(function () {
throw new Error('Test should fail but was succeed');
}) By encapsulating it in it('Should fail when the first argument is invisible', function () {
return runTests('./click.test.js', 'Should fail when the first argument is invisible', { shouldFail: true })
.catch(function (err) {
var expectedError = [
'Error at step "1.Click on invisible element":',
'',
'act.click($input);',
'',
'A target element \<input id="input"\> of the click action is not visible.',
'If this element should appear when you are hovering over another',
'element, make sure that you properly recorded the hover action.'
].join(' ');
expect(err['Should fail when the first argument is invisible']).eql(expectedError);
});
}); Also, maybe if test name is explicitly specified we could return just this test's error, so it will be: expect(err).eql(expectedError) What do you guys think? |
I suppose, it'll be useful. @georgiy-abbasov let's implement this. If we specify the test name, |
…ness-as-mocha-test Functional harness implemented (#52)
I guess we can close it now, since we use functional testing heavily to cover functionality. |
This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow. |
No description provided.
The text was updated successfully, but these errors were encountered: