Skip to content

Commit

Permalink
Switch to hammerhead 9.0.0. Separate replicators (part of #524). Bump…
Browse files Browse the repository at this point in the history
… version. (#555)

* Switch to hammerhead v9.0.0

* Use separate instances for server and client replicator

* Bump version.
  • Loading branch information
inikulin authored and kirovboris committed May 26, 2016
1 parent b6c02ad commit c73bd3c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "testcafe",
"version": "0.0.16",
"version": "0.0.17",
"main": "lib/index",
"bin": {
"testcafe": "./bin/testcafe"
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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
});
4 changes: 2 additions & 2 deletions src/compiler/es-next/compile-hybrid-function.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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
];
Expand Down
12 changes: 3 additions & 9 deletions src/test-run/commands/replicator.js
Original file line number Diff line number Diff line change
@@ -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
});

0 comments on commit c73bd3c

Please sign in to comment.