Skip to content

Commit

Permalink
fix tests 3
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and [email protected] committed Sep 13, 2018
1 parent 7e3f14c commit f42ae04
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
"broken-link-checker": "^0.7.0",
"browserstack-connector": "^0.1.5",
"caller": "^1.0.1",
"chai-string": "^1.5.0",
"connect": "^3.4.0",
"cross-spawn": "^4.0.0",
"dom-walk": "^0.1.1",
Expand Down
2 changes: 1 addition & 1 deletion src/client/automation/playback/rclick.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const extend = hammerhead.utils.extend;
const browserUtils = hammerhead.utils.browser;
const eventSimulator = hammerhead.eventSandbox.eventSimulator;

const { domUtils, eventUtils, delay } = testCafeCore.domUtils;
const { domUtils, eventUtils, delay } = testCafeCore;

export default class RClickAutomation extends VisibleElementAutomation {
constructor (element, clickOptions) {
Expand Down
12 changes: 8 additions & 4 deletions test/functional/fixtures/api/es-next/take-screenshot/test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
const path = require('path');
const fs = require('fs');
const expect = require('chai').expect;
const chai = require('chai');
const { expect } = chai;
const config = require('../../../../config.js');
const assertionHelper = require('../../../../assertion-helper.js');

chai.use(require('chai-string'));

const SCREENSHOTS_PATH = assertionHelper.SCREENSHOTS_PATH;
const THUMBNAILS_DIR_NAME = assertionHelper.THUMBNAILS_DIR_NAME;
const SCREENSHOT_PATH_MESSAGE_RE = /^___test-screenshots___[\\/]\d{4,4}-\d{2,2}-\d{2,2}_\d{2,2}-\d{2,2}-\d{2,2}[\\/]test-1$/;
const SCREENSHOT_PATH_MESSAGE_RE = /^___test-screenshots___[\\/]\d{4,4}-\d{2,2}-\d{2,2}_\d{2,2}-\d{2,2}-\d{2,2}[\\/]test-1/;
const SCREENSHOT_ON_FAIL_PATH_MESSAGE_RE = /^.*run-1/;
const SLASH_RE = /[\\/]/g;

var getReporter = function (scope) {
const getReporter = function (scope) {
const userAgents = { };

function patchScreenshotPath (screenshotPath) {
Expand Down Expand Up @@ -60,7 +63,8 @@ describe('[API] t.takeScreenshot()', function () {
return runTests('./testcafe-fixtures/take-screenshot.js', 'Take a screenshot with a custom path (OS separator)',
{ setScreenshotPath: true })
.then(function () {
expect(testReport.screenshotPath).eql(path.join(SCREENSHOTS_PATH, 'custom'));

expect(testReport.screenshotPath).startsWith(path.join(SCREENSHOTS_PATH, 'custom'));

const screenshotsCheckingOptions = { forError: false, screenshotsCount: 2, customPath: 'custom' };

Expand Down
33 changes: 16 additions & 17 deletions test/functional/fixtures/api/legacy/smoke/test.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
var expect = require('chai').expect;
var globby = require('globby').sync;
var path = require('path');
var config = require('../../../../config');
var assertionHelper = require('../../../../assertion-helper');
const { expect } = require('chai');
const { sync: globby } = require('globby');
const path = require('path');
const config = require('../../../../config');
const assertionHelper = require('../../../../assertion-helper');

const SCREENSHOT_PATH_MESSAGE_RE = /^___test-screenshots___[\\/]\d{4,4}-\d{2,2}-\d{2,2}_\d{2,2}-\d{2,2}-\d{2,2}[\\/]test-1/;
const ERROR_SCREENSHOT_PATH_RE = /Screenshot: ___test-screenshots___[\\/]\d{4,4}-\d{2,2}-\d{2,2}_\d{2,2}-\d{2,2}-\d{2,2}[\\/]test-1[\\/]\S+[\\/]errors[\\/]\d.png/;

var SCREENSHOT_PATH_MESSAGE_RE = /^___test-screenshots___[\\/]\d{4,4}-\d{2,2}-\d{2,2}_\d{2,2}-\d{2,2}-\d{2,2}[\\/]test-1$/;
var ERROR_SCREENSHOT_PATH_RE = /Screenshot: ___test-screenshots___[\\/]\d{4,4}-\d{2,2}-\d{2,2}_\d{2,2}-\d{2,2}-\d{2,2}[\\/]test-1[\\/]\S+[\\/]errors[\\/]\d.png/;

describe('[Legacy] Smoke tests', function () {
it('Should run basic tests', function () {
describe('[Legacy] Smoke tests', () => {
it('Should run basic tests', () => {
return runTests(globby(path.join(__dirname, './testcafe-fixtures/basic/*test.js')), null, { skip: 'iphone,ipad' });
});

it('Should fail on errors', function () {
it('Should fail on errors', () => {
return runTests('./testcafe-fixtures/errors.test.js', null, { shouldFail: true, skip: 'iphone,ipad' })
.catch(function (errs) {
.catch(errs => {
expect(errs[0]).contains('A target element of the click action has not been found in the DOM tree.');
});
});

if (config.useLocalBrowsers) {
describe('Screenshots', function () {
describe('Screenshots', () => {
afterEach(assertionHelper.removeScreenshotDir);

it('Should take a screenshot', function () {
it('Should take a screenshot', () => {
return runTests('./testcafe-fixtures/screenshots.test.js', 'Take a screenshot', { setScreenshotPath: true })
.then(function () {
.then(() => {
expect(SCREENSHOT_PATH_MESSAGE_RE.test(testReport.screenshotPath)).eql(true);
expect(assertionHelper.checkScreenshotsCreated({ forError: false, screenshotsCount: 2 })).eql(true);
});
});

it('Should take a screenshot if an error in test code is raised', function () {
it('Should take a screenshot if an error in test code is raised', () => {
return runTests('./testcafe-fixtures/screenshots.test.js', 'Screenshot on test code error',
{ shouldFail: true, screenshotsOnFails: true, setScreenshotPath: true })
.catch(function (errs) {
.catch(errs => {
assertionHelper.errorInEachBrowserContainsRegExp(errs, ERROR_SCREENSHOT_PATH_RE, 0);
expect(assertionHelper.checkScreenshotsCreated({ forError: true })).eql(true);
});
Expand Down

0 comments on commit f42ae04

Please sign in to comment.