Skip to content
Permalink
Browse files

Merge ce562d2 into b5b5b78

  • Loading branch information...
alexjeffburke committed Aug 25, 2019
2 parents b5b5b78 + ce562d2 commit 8c23e4a21fbaa561a7154177e8cfcc5099131cb6
Showing with 225 additions and 146 deletions.
  1. +1 −0 .eslintignore
  2. +2 −1 .eslintrc
  3. +2 −0 .gitignore
  4. +1 −0 .prettierignore
  5. +3 −0 .travis.yml
  6. +17 −4 Makefile
  7. +7 −2 lib/defaultDepth.js
  8. +3 −5 lib/useFullStackTrace.js
  9. +10 −0 lib/utils.js
  10. +5 −2 package.json
  11. +21 −15 rollup.config.js
  12. +7 −0 rollup.tests.js
  13. +11 −0 test-deno/deno-setup.js
  14. +8 −0 test-deno/deno-test.js
  15. +21 −14 test/common.js
  16. +106 −103 test/types/function-type.spec.js
@@ -4,3 +4,4 @@
/coverage/
/site-build/
/unexpected.js
/unexpected-deno.js
@@ -10,7 +10,8 @@
{
"devDependencies": [
"**/test/**/*.js",
"**/bootstrap-unexpected-markdown.js"
"**/bootstrap-unexpected-markdown.js",
"rollup.tests.js"
],
"optionalDependencies": false,
"peerDependencies": false
@@ -8,3 +8,5 @@
/.nyc_output/
/unexpected.js
/unexpected.js.map
/unexpected.esm.js
/unexpected.esm.js.map
@@ -3,6 +3,7 @@
/coverage/
/site-build/
/unexpected.js
/unexpected-deno.js

# Don't battle npm i --save
/package.json
@@ -32,6 +32,9 @@ matrix:
- name: Chrome headless
node_js: '8.7.0'
env: TARGET=test-chrome-headless
- name: Deno
node_js: '8.7.0'
env: TARGET=test-deno

addons:
chrome: stable
@@ -1,8 +1,8 @@
REPORTER = dot

TARGETS ?= unexpected.js unexpected.js.map
.PHONY: unexpected.js
.SECONDARY: unexpected.js.map
TARGETS ?= unexpected.js unexpected.js.map unexpected.esm.js unexpected.esm.js.map
.PHONY: unexpected.js unexpected-deno.js
.SECONDARY: unexpected.js.map unexpected-deno.js.map

CHEWBACCA_THRESHOLD ?= 25

@@ -31,9 +31,15 @@ build/externaltests: externaltests/*

build: build/lib build/test build/externaltests

${TARGETS}: build
build/tests.esm.js: build/test
./node_modules/.bin/rollup --config rollup.tests.js > build/tests.esm.js

unexpected.js unexpected.js.map: build
./node_modules/.bin/rollup --config rollup.config.js --sourcemap --format umd --name weknowhow.expect -o unexpected.js build/lib/index.js

unexpected.esm.js unexpected.esm.js.map: build
ESM_BUILD=yes ./node_modules/.bin/rollup --config rollup.config.js --sourcemap --format esm --name weknowhow.expect -o unexpected.esm.js build/lib/index.js

test-jasmine:
./node_modules/.bin/jasmine JASMINE_CONFIG_PATH=test/support/jasmine.json

@@ -90,6 +96,13 @@ test-browserstack-%: ${TARGETS}
test-plugins: ${TARGETS}
./node_modules/.bin/fugl --config .fugl.json --reporter html --ci

.PHONY: test-deno
test-deno: ${TARGETS} build/tests.esm.js
if [ ! -f ~/.deno/bin/deno ]; then \
curl -fsSL https://deno.land/x/install/install.sh | sh; \
fi;
~/.deno/bin/deno test-deno/deno-test.js

.PHONY: travis-coverage
travis-coverage: clean coverage
-<coverage/lcov.info ./node_modules/coveralls/bin/coveralls.js
@@ -1,3 +1,5 @@
const utils = require('./utils');

let defaultDepth = 3;
const matchDepthParameter =
typeof window !== 'undefined' &&
@@ -6,7 +8,10 @@ const matchDepthParameter =

if (matchDepthParameter) {
defaultDepth = parseInt(matchDepthParameter[1], 10);
} else if (typeof process !== 'undefined' && process.env.UNEXPECTED_DEPTH) {
defaultDepth = parseInt(process.env.UNEXPECTED_DEPTH, 10);
} else {
const defaultDepthFromEnv = utils.getEnv('UNEXPECTED_DEPTH');
if (defaultDepthFromEnv) {
defaultDepth = parseInt(defaultDepthFromEnv, 10);
}
}
module.exports = defaultDepth;
@@ -1,16 +1,14 @@
const Promise = require('unexpected-bluebird');
const utils = require('./utils');

let useFullStackTrace = false;
if (typeof window !== 'undefined' && typeof window.location !== 'undefined') {
useFullStackTrace = !!window.location.search.match(
/[?&]full-trace=true(?:$|&)/
);
}

if (
typeof process !== 'undefined' &&
process.env &&
process.env.UNEXPECTED_FULL_TRACE
) {
if (utils.getEnv('UNEXPECTED_FULL_TRACE')) {
Promise.longStackTraces();
useFullStackTrace = true;
}
@@ -1,4 +1,6 @@
/* eslint-disable no-proto */
/* global Deno */

const canSetPrototype =
Object.setPrototypeOf || { __proto__: [] } instanceof Array;
const greedyIntervalPacker = require('greedy-interval-packer');
@@ -358,5 +360,13 @@ const utils = (module.exports = {
} else {
return subject.substring(contextLength, subject.length);
}
},

getEnv(varName) {
if (typeof Deno === 'object' && Deno.permissions().env) {
return Deno.env()[varName];
} else if (typeof process === 'object' && process.env) {
return process.env[varName];
}
}
});
@@ -28,7 +28,7 @@
"diff": "4.0.1",
"greedy-interval-packer": "1.2.0",
"leven": "2.1.0",
"magicpen": "^6.0.2",
"magicpen": "git://github.com/alexjeffburke/magicpen.git#feature/deno",
"unexpected-bluebird": "2.9.34-longstack2"
},
"devDependencies": {
@@ -63,18 +63,21 @@
"prettier": "~1.18.2",
"rollup": "^1.0.1",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-multi-entry": "^2.1.0",
"rollup-plugin-node-globals": "^1.1.0",
"rollup-plugin-node-resolve": "^5.0.0",
"rollup-plugin-terser": "^5.0.0",
"rsvp": "^4.7.0",
"serve": "*",
"unexpected-documentation-site-generator": "^6.0.0",
"unexpected-magicpen": "^2.0.0",
"unexpected-magicpen": "git://github.com/unexpectedjs/unexpected-magicpen.git#feature/deno",
"unexpected-markdown": "^4.0.0"
},
"files": [
"unexpected.js",
"unexpected.js.map",
"unexpected.esm.js",
"unexpected.esm.js.map",
"lib",
"build/lib"
],
@@ -1,5 +1,23 @@
var fs = require('fs');
var pathModule = require('path');
const fs = require('fs');
const pathModule = require('path');

const plugins = [
/* eslint import/no-extraneous-dependencies: ["error", {"devDependencies": true}] */
require('rollup-plugin-commonjs')({
// leave the os require in the tree as that codepath is not
// taken when executed in Deno after magicpen porting work
ignore: process.env.ESM_BUILD ? ['os'] : undefined
}),
require('rollup-plugin-node-resolve')({ preferBuiltins: true }),
require('rollup-plugin-node-globals')(),
require('rollup-plugin-terser').terser({
output: {
comments: function(node, comment) {
return /^!|@preserve|@license|@cc_on/i.test(comment.value);
}
}
})
];

module.exports = {
output: {
@@ -11,17 +29,5 @@ module.exports = {
.replace(/\s+$/g, '') +
'/\n'
},
plugins: [
/* eslint import/no-extraneous-dependencies: ["error", {"devDependencies": true}] */
require('rollup-plugin-commonjs')(),
require('rollup-plugin-node-resolve')(),
require('rollup-plugin-node-globals')(),
require('rollup-plugin-terser').terser({
output: {
comments: function(node, comment) {
return /^!|@preserve|@license|@cc_on/i.test(comment.value);
}
}
})
]
plugins
};
@@ -0,0 +1,7 @@
module.exports = {
input: 'build/test/**/*.js',
output: {
format: 'esm'
},
plugins: require('rollup-plugin-multi-entry')({ exports: false })
};
@@ -0,0 +1,11 @@
import '../node_modules/mocha/mocha.js';
import unexpected from '../unexpected.esm.js';
import unexpectedMagicPen from '../node_modules/unexpected-magicpen/unexpected-magicpen.esm.js';

window.mocha.reporter('spec');
window.mocha.setup('bdd');

window.weknowhow = {
expect: unexpected,
unexpectedMagicPen: unexpectedMagicPen
};
@@ -0,0 +1,8 @@
/* globals Deno */
import './deno-setup.js';
import '../test/common.js';
import '../build/tests.esm.js';

window.mocha.run(failureCount => {
Deno.exit(failureCount > 0 ? 1 : 0);
});
@@ -1,9 +1,9 @@
/* global unexpected:true, expect:true, expectWithUnexpectedMagicPen:true, weknowhow, jasmine */
/* eslint no-unused-vars: "off" */
unexpected =
typeof weknowhow === 'undefined'
var unexpected =
typeof window === 'undefined' || !window.weknowhow
? require('../lib/').clone()
: weknowhow.expect.clone();
: window.weknowhow.expect.clone();

unexpected.output.preferredWidth = 80;

@@ -43,23 +43,30 @@ unexpected
});
});

expect = unexpected.clone();
var expect = unexpected.clone();

expectWithUnexpectedMagicPen = unexpected
var expectWithUnexpectedMagicPen = unexpected
.clone()
.use(
typeof weknowhow === 'undefined'
? require('unexpected-magicpen')
: weknowhow.unexpectedMagicPen
);

if (typeof setImmediate !== 'function') {
// eslint-disable-next-line no-global-assign
setImmediate = function(cb) {
setTimeout(cb, 0);
};
}
(function(root) {
// expose require globals
root.unexpected = unexpected;
root.expect = expect;
root.expectWithUnexpectedMagicPen = expectWithUnexpectedMagicPen;

if (typeof jasmine !== 'undefined') {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
}
if (!root.setImmediate) {
// eslint-disable-next-line no-global-assign
root.setImmediate = function(cb) {
setTimeout(cb, 0);
};
}

if (root.jasmine) {
root.jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
}
})(typeof window !== 'undefined' ? window : global);

0 comments on commit 8c23e4a

Please sign in to comment.
You can’t perform that action at this time.