diff --git a/package.json b/package.json index 75fe5b759c9..591688e5cf7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "testcafe", - "version": "0.0.16", + "version": "0.0.17", "main": "lib/index", "bin": { "testcafe": "./bin/testcafe" @@ -46,8 +46,8 @@ "stack-chain": "^1.3.6", "strip-bom": "^2.0.0", "testcafe-browser-natives": "^0.10.0", - "testcafe-hammerhead": "^8.1.0", - "testcafe-legacy-api": "^0.3.0", + "testcafe-hammerhead": "^9.0.0", + "testcafe-legacy-api": "^0.4.0", "testcafe-reporter-json": "^1.0.0", "testcafe-reporter-list": "^1.0.0", "testcafe-reporter-minimal": "^1.0.0", diff --git a/src/client/driver/command-executors/execute-client-code.js b/src/client/driver/command-executors/execute-client-code/index.js similarity index 78% rename from src/client/driver/command-executors/execute-client-code.js rename to src/client/driver/command-executors/execute-client-code/index.js index 91afa240157..1260cc59636 100644 --- a/src/client/driver/command-executors/execute-client-code.js +++ b/src/client/driver/command-executors/execute-client-code/index.js @@ -1,7 +1,7 @@ -import hammerhead from '../deps/hammerhead'; -import DriverStatus from '../status'; -import replicator from '../../../test-run/commands/replicator'; -import { UncaughtErrorInClientExecutedCode } from '../../../errors/test-run'; +import hammerhead from '../../deps/hammerhead'; +import DriverStatus from '../../status'; +import replicator from './replicator'; +import { UncaughtErrorInClientExecutedCode } from '../../../../errors/test-run'; var Promise = hammerhead.Promise; diff --git a/src/client/driver/command-executors/execute-client-code/replicator.js b/src/client/driver/command-executors/execute-client-code/replicator.js new file mode 100644 index 00000000000..e574db318da --- /dev/null +++ b/src/client/driver/command-executors/execute-client-code/replicator.js @@ -0,0 +1,12 @@ +import Replicator from 'replicator'; + +var identityFn = val => val; + +// NOTE: we will serialize replicator results +// to JSON with a command or command result. +// Therefore there is no need to do additional job here, +// so we use identity functions for serialization. +export default new Replicator({ + serialize: identityFn, + deserialize: identityFn +}); diff --git a/src/compiler/es-next/compile-hybrid-function.js b/src/compiler/es-next/compile-hybrid-function.js index d8d07ddb763..9c9d3b9625a 100644 --- a/src/compiler/es-next/compile-hybrid-function.js +++ b/src/compiler/es-next/compile-hybrid-function.js @@ -1,4 +1,4 @@ -import { wrapDomAccessors } from 'testcafe-hammerhead'; +import hammerhead from 'testcafe-hammerhead'; import asyncToGenerator from 'babel-runtime/helpers/asyncToGenerator'; import { noop, escapeRegExp as escapeRe } from 'lodash'; import loadBabelLibs from './load-babel-libs'; @@ -120,7 +120,7 @@ export default function compileHybridFunction (fnCode, dependencies = {}, callsi if (NODE_VER >= 4) fnCode = downgradeES(fnCode); - fnCode = wrapDomAccessors(fnCode, true); + fnCode = hammerhead.processScript(fnCode, false); // NOTE: check compiled code for regenerator injection: we have either generator // recompiled in Node.js 4+ for client or async function declared in function code. diff --git a/src/compiler/index.js b/src/compiler/index.js index a0ddc80e185..b7346623ede 100644 --- a/src/compiler/index.js +++ b/src/compiler/index.js @@ -2,7 +2,7 @@ import * as fs from 'fs'; import { flattenDeep as flatten, find } from 'lodash'; import stripBom from 'strip-bom'; import { Compiler as LegacyCompiler } from 'testcafe-legacy-api'; -import { wrapDomAccessors } from 'testcafe-hammerhead'; +import hammerhead from 'testcafe-hammerhead'; import EsNextCompiler from './es-next'; import RawFileCompiler from './raw-file'; import { GeneralError } from '../errors/runtime'; @@ -18,7 +18,7 @@ export default class Compiler { this.rawDataCompiler = new RawFileCompiler(); this.compilers = [ - new LegacyCompiler(wrapDomAccessors), + new LegacyCompiler(hammerhead.processScript), this.esNextCompiler, this.rawDataCompiler ]; diff --git a/src/test-run/commands/replicator.js b/src/test-run/commands/replicator.js index b7da538a054..0a4a0a92885 100644 --- a/src/test-run/commands/replicator.js +++ b/src/test-run/commands/replicator.js @@ -1,17 +1,11 @@ -// ------------------------------------------------------------- -// WARNING: this file is used by both the client and the server. -// Do not use any browser or node-specific API! -// ------------------------------------------------------------- - +import { identity } from 'lodash'; import Replicator from 'replicator'; -var identityFn = val => val; - // NOTE: we will serialize replicator results // to JSON with a command or command result. // Therefore there is no need to do additional job here, // so we use identity functions for serialization. export default new Replicator({ - serialize: identityFn, - deserialize: identityFn + serialize: identity, + deserialize: identity });