Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testing resolving and bundling shims with depends
- Loading branch information
Showing
3 changed files
with
32 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
/*jshint asi: true */ | ||
|
||
var browserify = require('browserify') | ||
, test = require('tap').test | ||
, vm = require('vm') | ||
|
||
function bundleNcheck(relPath, t) { | ||
browserify( { ignoreGlobals: true }) | ||
.require(require.resolve(relPath)) | ||
.bundle(function (err, src) { | ||
if (err) { t.fail(err); return t.end(); } | ||
|
||
var ctx = { window: {}, console: console }; | ||
ctx.self = ctx.window; | ||
var require_ = vm.runInNewContext(src, ctx); | ||
|
||
var main = require_(require.resolve(relPath)); | ||
|
||
t.deepEqual(main(), { noncjs: { name: 'non-cjs', version: 1.1 } }, 'shims non-cjs, requireing non-cjs-dep '); | ||
t.end() | ||
}); | ||
} | ||
|
||
test('\nshimming deps with external shim, with depends all exposed' | ||
, bundleNcheck.bind(null, './deps/extshim/main')) | ||
|
||
test('\nshimming nodeps with inlined shim, with depends all exposed' | ||
, bundleNcheck.bind(null, './deps/inlineshim/main')) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters