refactor(@embark/test-runner): move test module into test-runner package

This commit is contained in:
Pascal Precht 2019-04-30 16:04:54 +02:00 committed by Pascal Precht
parent 03d779ef5e
commit baf6f20066
13 changed files with 101 additions and 14 deletions

View File

@ -63,10 +63,6 @@
"initiated": "initiated",
"restart": "restart"
},
"tests": {
"gasLimit": 6000000,
"coverageGasLimit": 4503599627370495
},
"codeGenerator": {
"gasLimit": 6000000
},

View File

@ -0,0 +1,4 @@
engine-strict = true
package-lock = false
save-exact = true
scripts-prepend-node-path = true

View File

@ -0,0 +1,6 @@
# `embark-test-runner`
Embark Testrunner
Visit [embark.status.im](https://embark.status.im/) to get started with
[Embark](https://github.com/embark-framework/embark).

View File

@ -0,0 +1,70 @@
{
"name": "embark-test-runner",
"version": "4.1.0-beta.0",
"author": "Iuri Matias <iuri.matias@gmail.com>",
"contributors": [],
"description": "Embark Testrunner",
"homepage": "https://github.com/embark-framework/embark/tree/master/packages/embark-test-runner#readme",
"bugs": "https://github.com/embark-framework/embark/issues",
"keywords": [
"blockchain",
"dapps",
"ethereum",
"ipfs",
"serverless",
"solc",
"solidity"
],
"files": [
"dist"
],
"license": "MIT",
"repository": {
"directory": "packages/embark-test-runner",
"type": "git",
"url": "https://github.com/embark-framework/embark.git"
},
"main": "./dist/index.js",
"scripts": {
"build": "cross-env BABEL_ENV=node babel src --extensions \".js,.ts\" --out-dir dist --root-mode upward --source-maps",
"ci": "npm run qa",
"clean": "npm run reset",
"lint": "npm-run-all lint:*",
"lint:js": "eslint src/",
"// lint:ts": "tslint -c tslint.json \"src/**/*.ts\"",
"package": "npm pack",
"// qa": "npm-run-all lint typecheck build package",
"qa": "npm-run-all lint build package",
"reset": "npx rimraf dist embark-*.tgz package",
"start": "npm run watch",
"// typecheck": "tsc",
"watch": "run-p watch:*",
"watch:build": "npm run build -- --verbose --watch",
"// watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch"
},
"eslintConfig": {
"extends": "../../.eslintrc.json"
},
"dependencies": {
"@babel/runtime-corejs2": "7.3.1",
"async": "2.6.1",
"embark-utils": "^4.1.0-beta.0",
"mocha": "5.2.0"
},
"devDependencies": {
"@babel/cli": "7.2.3",
"@babel/core": "7.2.2",
"@types/async": "2.0.50",
"cross-env": "5.2.0",
"eslint": "5.7.0",
"npm-run-all": "4.1.5",
"rimraf": "2.6.3",
"tslint": "5.11.0",
"typescript": "3.3.1"
},
"engines": {
"node": ">=8.12.0",
"npm": ">=6.4.1",
"yarn": ">=1.12.3"
}
}

View File

@ -0,0 +1,2 @@
export const COVERAGE_GAS_LIMIT = 4503599627370495;
export const GAS_LIMIT = 6000000;

View File

@ -6,7 +6,7 @@ const assert = require('assert');
const Test = require('./test');
const {EmbarkSpec, EmbarkApiSpec} = require('./reporter');
const SolcTest = require('./solc_test');
const constants = require('embark-core/constants');
import { COVERAGE_GAS_LIMIT, GAS_LIMIT } from './constants';
class TestRunner {
constructor(embark, options) {
@ -156,7 +156,7 @@ class TestRunner {
runJSTests(files, options, cb) {
const self = this;
const test = new Test({loglevel: options.loglevel, node: options.node, events: self.events, logger: self.logger,
config: self.embark.config, ipc: self.ipc, coverage: options.coverage, inProcess: options.inProcess});
config: self.embark.config, ipc: self.ipc, coverage: options.coverage, inProcess: options.inProcess, dappPath: this.embark.fs.dappPath()});
async.waterfall([
function setupGlobalNamespace(next) {
global.embark = test;
@ -207,7 +207,7 @@ class TestRunner {
let fns = files.map((file) => {
return (cb) => {
const mocha = new Mocha();
const gasLimit = options.coverage ? constants.tests.coverageGasLimit : constants.tests.gasLimit;
const gasLimit = options.coverage ? COVERAGE_GAS_LIMIT : GAS_LIMIT;
const reporter = options.inProcess ? EmbarkApiSpec : EmbarkSpec;
mocha.reporter(reporter, {
events: self.events,

View File

@ -1,7 +1,7 @@
const Base = require('mocha/lib/reporters/base');
const ms = require('mocha/lib/ms');
const color = Base.color;
import {getAddressToContract, getTransactionParams} from 'embark-utils';
import { getAddressToContract, getTransactionParams } from 'embark-utils';
class EmbarkApiSpec extends Base {
constructor(runner, options) {

View File

@ -1,8 +1,8 @@
import { deconstructUrl, prepareContractsConfig, AccountParser } from 'embark-utils';
const async = require('async');
const constants = require('embark-core/constants');
const web3Utils = require('web3-utils');
import { GAS_LIMIT } from './constants';
const BALANCE_10_ETHER_IN_HEX = '0x8AC7230489E80000';
@ -24,6 +24,7 @@ class Test {
this.provider = null;
this.accounts = [];
this.embarkjs = {};
this.dappPath = options.dappPath;
this.events.setCommandHandler("blockchain:provider:contract:accounts:get", cb => {
this.events.request("blockchain:getAccounts", cb);
@ -36,7 +37,7 @@ class Test {
this.events.request('runcode:ready', next);
},
(next) => {
this.gasLimit = constants.tests.gasLimit;
this.gasLimit = GAS_LIMIT;
this.events.request('deploy:setGasLimit', this.gasLimit);
if (this.options.node !== 'embark') {
this.showNodeHttpWarning();
@ -153,7 +154,7 @@ class Test {
this.events.request("blockchain:get", (web3) => {
if (accounts) {
self.simOptions.accounts = AccountParser.parseAccountsConfig(accounts, web3);
self.simOptions.accounts = AccountParser.parseAccountsConfig(accounts, web3, this.dappPath);
} else {
self.simOptions.accounts = null;
}
@ -353,7 +354,7 @@ class Test {
abi: ${JSON.stringify(contract.abiDefinition)},
address: "${contract.deployedAddress || ""}" || undefined,
from: "${contract.deploymentAccount || ""}" || web3.eth.defaultAccount,
gas: "${constants.tests.gasLimit}",
gas: "${GAS_LIMIT}",
web3: web3
});
@ -364,7 +365,7 @@ class Test {
if (newContract.options.data && !newContract.options.data.startsWith('0x')) {
newContract.options.data = '0x' + newContract.options.data;
}
newContract.options.gas = "${constants.tests.gasLimit}";
newContract.options.gas = "${GAS_LIMIT}";
}
return newContract;`;
this.events.request("runcode:eval", codeToRun, cb, false, true);

View File

@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"]
}

View File

@ -0,0 +1,3 @@
{
"extends": "../../tslint.json"
}

View File

@ -105,6 +105,7 @@
"embark-specialconfigs": "^4.1.0-beta.0",
"embark-scaffolding": "^4.1.0-beta.0",
"embark-ui": "^4.1.0-beta.0",
"embark-test-runner": "^4.1.0-beta.0",
"embark-transaction-tracker": "^4.1.0-beta.0",
"embark-utils": "^4.1.0-beta.0",
"embark-vyper": "^4.0.0",

View File

@ -324,7 +324,7 @@ class Engine {
}
testRunnerService(options) {
this.registerModule('tests', Object.assign(options, {ipc: this.ipc}));
this.registerModulePackage('embark-test-runner', Object.assign(options, {ipc: this.ipc}));
}
}