FIX browser-tests

pull/15/head
pubkey 7 years ago
parent 95025be7e7
commit c14636e971
  1. 1
      .gitignore
  2. 1
      .npmignore
  3. 1
      .travis.yml
  4. 49
      config/karma.conf.js
  5. 16
      package.json
  6. 9
      test/issues.test.js
  7. 3
      test/karma.test.js
  8. 14
      test/performance.test.js

1
.gitignore vendored

@ -4,3 +4,4 @@ core
log.txt log.txt
package-lock.json package-lock.json
gen/ gen/
test_tmp/

@ -6,3 +6,4 @@
package-lock.json package-lock.json
gen/ gen/
scripts/ scripts/
test_tmp/

@ -1,4 +1,5 @@
language: node_js language: node_js
sudo: required
os: os:
- linux - linux
node_js: node_js:

@ -2,41 +2,64 @@ const configuration = {
basePath: '', basePath: '',
frameworks: [ frameworks: [
'mocha', 'mocha',
'browserify' 'browserify',
'detectBrowsers'
], ],
files: [ files: [
'../test/unit.test.js', '../test_tmp/karma.test.js'
'../test/issues.test.js',
'../test/performance.test.js'
], ],
port: 9876, port: 9876,
colors: true, colors: true,
autoWatch: false, autoWatch: false,
/**
* see
* @link https://github.com/litixsoft/karma-detect-browsers
*/
detectBrowsers: {
enabled: true,
usePhantomJS: false,
postDetection: function(availableBrowser) {
return ['Firefox']; // comment in to test specific browser
const browsers = availableBrowser
.filter(b => !['PhantomJS', 'FirefoxAurora', 'FirefoxNightly'].includes(b))
.map(b => {
if (b === 'Chrome') return 'Chrome_travis_ci';
else return b;
});
return browsers;
}
},
// Karma plugins loaded // Karma plugins loaded
plugins: [ plugins: [
'karma-mocha', 'karma-mocha',
'karma-browserify', 'karma-browserify',
'karma-chrome-launcher' 'karma-chrome-launcher',
'karma-edge-launcher',
'karma-firefox-launcher',
'karma-ie-launcher',
'karma-opera-launcher',
'karma-detect-browsers'
], ],
// Source files that you wanna generate coverage for. // Source files that you wanna generate coverage for.
// Do not include tests or libraries (these files will be instrumented by Istanbul) // Do not include tests or libraries (these files will be instrumented by Istanbul)
preprocessors: { preprocessors: {
'../test/*.test.js': ['browserify'] '../test_tmp/*.test.js': ['browserify']
}, },
client: { client: {
mocha: { mocha: {
bail: true, bail: true,
timeout: 6000 timeout: 12000
} }
}, },
browsers: ['ChromeNoSandbox'], browsers: ['Chrome_travis_ci'],
browserDisconnectTimeout: 6000, browserDisconnectTimeout: 12000,
processKillTimeout: 6000, processKillTimeout: 12000,
customLaunchers: { customLaunchers: {
ChromeNoSandbox: { Chrome_travis_ci: {
base: 'Chrome', base: 'Chrome',
flags: ['--no-sandbox'] flags: ['--no-sandbox']
} }
@ -45,12 +68,12 @@ const configuration = {
}; };
if (process.env.TRAVIS) { if (process.env.TRAVIS) {
configuration.browsers = ['Chrome_travis_ci'];
/** /**
* overwrite reporters-default * overwrite reporters-default
* So no big list will be shown at log * So no big list will be shown at log
*/ */
// configuration.reporters = []; configuration.reporters = [];
} }
module.exports = function(config) { module.exports = function(config) {

@ -25,11 +25,12 @@
"test:node": "npm run build && mocha ./test/index.test.js -b --timeout 6000 --exit", "test:node": "npm run build && mocha ./test/index.test.js -b --timeout 6000 --exit",
"test:browser": "npm run build && karma start ./config/karma.conf.js --single-run", "test:browser": "npm run build && karma start ./config/karma.conf.js --single-run",
"lint": "eslint --ignore-path ./config/.eslintignore src test config scripts && solhint \"contracts/**/*.sol\"", "lint": "eslint --ignore-path ./config/.eslintignore src test config scripts && solhint \"contracts/**/*.sol\"",
"clear": "rimraf -rf ./dist && rimraf -rf ./gen", "clear": "rimraf -rf ./dist && rimraf -rf ./gen && rimraf -rf ./test_tmp",
"build:sol": "solidity-cli -i './contracts/*.sol' -o ./gen", "build:sol": "solidity-cli -i './contracts/*.sol' -o ./gen",
"build:es6": "rimraf -rf dist/es && cross-env NODE_ENV=es6 babel src --out-dir dist/es", "build:es6": "rimraf -rf dist/es && cross-env NODE_ENV=es6 babel src --out-dir dist/es",
"build:es5": "cross-env NODE_ENV=es5 node node_modules/babel-cli/bin/babel.js src --out-dir dist/lib", "build:es5": "cross-env NODE_ENV=es5 node node_modules/babel-cli/bin/babel.js src --out-dir dist/lib",
"build": "npm run clear && concurrently \"npm run build:es6\" \"npm run build:es5\" \"npm run build:sol\"" "build:test": "cross-env NODE_ENV=es5 node node_modules/babel-cli/bin/babel.js test --out-dir test_tmp",
"build": "npm run clear && concurrently \"npm run build:es6\" \"npm run build:es5\" \"npm run build:test\" \"npm run build:sol\""
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -43,7 +44,7 @@
"homepage": "https://github.com/pubkey/eth-crypto#readme", "homepage": "https://github.com/pubkey/eth-crypto#readme",
"devDependencies": { "devDependencies": {
"assert": "1.4.1", "assert": "1.4.1",
"async-test-util": "1.5.1", "async-test-util": "1.6.1",
"babel-cli": "6.26.0", "babel-cli": "6.26.0",
"babel-core": "6.26.3", "babel-core": "6.26.3",
"babel-eslint": "8.2.3", "babel-eslint": "8.2.3",
@ -70,15 +71,22 @@
"cross-env": "5.1.6", "cross-env": "5.1.6",
"eslint": "4.19.1", "eslint": "4.19.1",
"ganache-cli": "6.1.0", "ganache-cli": "6.1.0",
"is-node": "1.0.2",
"js-sha3": "0.7.0", "js-sha3": "0.7.0",
"karma": "2.0.2", "karma": "2.0.2",
"karma-babel-preprocessor": "7.0.0", "karma-babel-preprocessor": "7.0.0",
"karma-browserify": "5.2.0", "karma-browserify": "5.2.0",
"karma-chrome-launcher": "2.2.0", "karma-chrome-launcher": "2.2.0",
"karma-coverage": "1.1.2", "karma-coverage": "1.1.2",
"karma-detect-browsers": "2.3.2",
"karma-edge-launcher": "0.4.2",
"karma-firefox-launcher": "1.1.0",
"karma-ie-launcher": "1.0.0",
"karma-mocha": "1.3.0", "karma-mocha": "1.3.0",
"karma-opera-launcher": "1.0.0",
"karma-safari-launcher": "1.0.0",
"mocha": "5.2.0", "mocha": "5.2.0",
"node": "10.1.0", "node": "10.3.0",
"rimraf": "2.6.2", "rimraf": "2.6.2",
"solhint": "1.2.1", "solhint": "1.2.1",
"solidity-cli": "1.0.1", "solidity-cli": "1.0.1",

@ -44,13 +44,4 @@ describe('issues.test.js', () => {
); );
assert.ok(signer); assert.ok(signer);
}); });
it('#6 web3 should not set window.Web3', () => {
if (typeof window !== 'undefined' && window){
const web3 = EthCrypto.util.web3;
assert.ok(web3);
assert.deepEqual(window.Web3, undefined);
}
});
}); });

@ -0,0 +1,3 @@
require('./unit.test');
require('./issues.test');
require('./performance.test');

@ -1,6 +1,4 @@
const convertHrtime = require('convert-hrtime');
const AsyncTestUtil = require('async-test-util'); const AsyncTestUtil = require('async-test-util');
const EthCrypto = require('../dist/lib/index'); const EthCrypto = require('../dist/lib/index');
const benchmark = { const benchmark = {
@ -11,19 +9,11 @@ const benchmark = {
}; };
const nowTime = () => { const nowTime = () => {
try { return AsyncTestUtil.performanceNow();
return process.hrtime();
} catch (err) {
return performance.now();
}
}; };
const elapsedTime = before => { const elapsedTime = before => {
try { return AsyncTestUtil.performanceNow() - before;
return convertHrtime(process.hrtime(before)).milliseconds;
} catch (err) {
return performance.now() - before;
}
}; };
describe('performance.test.js', () => { describe('performance.test.js', () => {

Loading…
Cancel
Save