diff --git a/test/function/custom-external-resolver-async/_config.js b/test/function/custom-external-resolver-async/_config.js index 34faf37..50e54fa 100644 --- a/test/function/custom-external-resolver-async/_config.js +++ b/test/function/custom-external-resolver-async/_config.js @@ -5,9 +5,11 @@ var Promise = require( 'sander' ).Promise; module.exports = { description: 'uses a custom external path resolver (asynchronous)', options: { - resolveExternal: function ( id, importer, options ) { - return Promise.resolve( path.resolve( __dirname, 'js_modules', id + '.js' ) ); - } + plugins: [{ + resolveId: function ( id, importer ) { + if ( importer && id[0] !== '.' ) return Promise.resolve( path.resolve( __dirname, 'js_modules', id + '.js' ) ); + } + }] }, exports: function ( exports ) { assert.ok( exports.success ); diff --git a/test/function/custom-external-resolver-sync/_config.js b/test/function/custom-external-resolver-sync/_config.js index 2cf6de7..859c36d 100644 --- a/test/function/custom-external-resolver-sync/_config.js +++ b/test/function/custom-external-resolver-sync/_config.js @@ -4,9 +4,11 @@ var assert = require( 'assert' ); module.exports = { description: 'uses a custom external path resolver (synchronous)', options: { - resolveExternal: function ( id, importer, options ) { - return path.resolve( __dirname, 'js_modules', id + '.js' ); - } + plugins: [{ + resolveId: function ( id, importer ) { + if ( importer && id[0] !== '.' ) return path.resolve( __dirname, 'js_modules', id + '.js' ); + } + }] }, exports: function ( exports ) { assert.ok( exports.success ); diff --git a/test/function/custom-loaders/_config.js b/test/function/custom-loaders/_config.js index 17e2b79..cd18c7a 100644 --- a/test/function/custom-loaders/_config.js +++ b/test/function/custom-loaders/_config.js @@ -3,15 +3,19 @@ var fs = require( 'fs' ); module.exports = { description: 'uses custom loaders, falling back to default', options: { - load: [ - function ( id ) { - if ( /foo\.js/.test( id ) ) { - return fs.readFileSync( id, 'utf-8' ).replace( '@', 1 ); + plugins: [ + { + load: function ( id ) { + if ( /foo\.js/.test( id ) ) { + return fs.readFileSync( id, 'utf-8' ).replace( '@', 1 ); + } } }, - function ( id ) { - if ( /bar\.js/.test( id ) ) { - return fs.readFileSync( id, 'utf-8' ).replace( '@', 2 ); + { + load: function ( id ) { + if ( /bar\.js/.test( id ) ) { + return fs.readFileSync( id, 'utf-8' ).replace( '@', 2 ); + } } } ] diff --git a/test/function/custom-path-resolver-async/_config.js b/test/function/custom-path-resolver-async/_config.js index c336d67..2d7539a 100644 --- a/test/function/custom-path-resolver-async/_config.js +++ b/test/function/custom-path-resolver-async/_config.js @@ -4,20 +4,22 @@ var assert = require( 'assert' ); module.exports = { description: 'uses a custom path resolver (asynchronous)', options: { - resolveId: function ( importee, importer ) { - var Promise = require( 'sander' ).Promise; - var resolved; + plugins: [{ + resolveId: function ( importee, importer ) { + var Promise = require( 'sander' ).Promise; + var resolved; - if ( path.normalize(importee) === path.resolve( __dirname, 'main.js' ) ) return importee; + if ( path.normalize(importee) === path.resolve( __dirname, 'main.js' ) ) return importee; - if ( importee === 'foo' ) { - resolved = path.resolve( __dirname, 'bar.js' ); - } else { - resolved = false; - } + if ( importee === 'foo' ) { + resolved = path.resolve( __dirname, 'bar.js' ); + } else { + resolved = false; + } - return Promise.resolve( resolved ); - } + return Promise.resolve( resolved ); + } + }] }, exports: function ( exports ) { assert.strictEqual( exports.path, require( 'path' ) ); diff --git a/test/function/custom-path-resolver-on-entry/_config.js b/test/function/custom-path-resolver-on-entry/_config.js index 5a983b2..0766b6c 100644 --- a/test/function/custom-path-resolver-on-entry/_config.js +++ b/test/function/custom-path-resolver-on-entry/_config.js @@ -10,22 +10,24 @@ module.exports = { description: 'applies custom resolver to entry point', //solo: true, options: { - resolveId: function ( importee, importer ) { - if ( importer === undefined ) { - return '@' + path.relative( __dirname, importee ); - } + plugins: [{ + resolveId: function ( importee, importer ) { + if ( importer === undefined ) { + return '@' + path.relative( __dirname, importee ); + } - if ( importer[0] === '@' ) { - return path.resolve( __dirname, importee ) + '.js'; - } - }, - load: function ( moduleId ) { - if ( moduleId[0] === '@' ) { - return cachedModules[ moduleId ]; - } + if ( importer[0] === '@' ) { + return path.resolve( __dirname, importee ) + '.js'; + } + }, + load: function ( moduleId ) { + if ( moduleId[0] === '@' ) { + return cachedModules[ moduleId ]; + } - return fs.readFileSync( moduleId, 'utf-8' ); - } + return fs.readFileSync( moduleId, 'utf-8' ); + } + }] }, exports: function ( exports ) { assert.equal( exports, 42 ); diff --git a/test/function/custom-path-resolver-plural-b/_config.js b/test/function/custom-path-resolver-plural-b/_config.js index 60a4d26..05cf37a 100644 --- a/test/function/custom-path-resolver-plural-b/_config.js +++ b/test/function/custom-path-resolver-plural-b/_config.js @@ -3,17 +3,21 @@ var assert = require( 'assert' ); module.exports = { description: 'resolver error is not caught', options: { - resolveId: [ - function () { - throw new Error( 'nope' ); + plugins: [ + { + resolveId: function () { + throw new Error( 'nope' ); + }, + load: function ( id ) { + if ( id === 'main' ) return 'assert.ok( false );' + } }, - function ( importee, importer ) { - return 'main'; + { + resolveId: function ( importee, importer ) { + return 'main'; + } } - ], - load: function ( id ) { - if ( id === 'main' ) return 'assert.ok( false );' - } + ] }, error: function ( err ) { assert.equal( err.message, 'nope' ); diff --git a/test/function/custom-path-resolver-plural/_config.js b/test/function/custom-path-resolver-plural/_config.js index dd63a44..69a5c7c 100644 --- a/test/function/custom-path-resolver-plural/_config.js +++ b/test/function/custom-path-resolver-plural/_config.js @@ -4,18 +4,22 @@ var assert = require( 'assert' ); module.exports = { description: 'uses custom path resolvers (plural)', options: { - resolveId: [ - function ( importee ) { - if ( importee[0] === '@' ) - return path.resolve( __dirname, 'globals-' + importee.slice( 1 ).toLowerCase() + '.js' ); + plugins: [ + { + resolveId: function ( importee ) { + if ( importee[0] === '@' ) + return path.resolve( __dirname, 'globals-' + importee.slice( 1 ).toLowerCase() + '.js' ); + }, + load: function ( id ) { + if ( id === '' ) return ''; + } }, - function ( importee ) { - if ( importee[0] === '!' ) return ''; + { + resolveId: function ( importee ) { + if ( importee[0] === '!' ) return ''; + } } - ], - load: function ( id ) { - if ( id === '' ) return ''; - } + ] }, exports: function ( exports ) { assert.strictEqual( exports.res, 0 ); diff --git a/test/function/custom-path-resolver-sync/_config.js b/test/function/custom-path-resolver-sync/_config.js index ee993e1..4e0b5bf 100644 --- a/test/function/custom-path-resolver-sync/_config.js +++ b/test/function/custom-path-resolver-sync/_config.js @@ -4,12 +4,14 @@ var assert = require( 'assert' ); module.exports = { description: 'uses a custom path resolver (synchronous)', options: { - resolveId: function ( importee, importer ) { - if ( path.normalize(importee) === path.resolve( __dirname, 'main.js' ) ) return importee; - if ( importee === 'foo' ) return path.resolve( __dirname, 'bar.js' ); + plugins: [{ + resolveId: function ( importee, importer ) { + if ( path.normalize(importee) === path.resolve( __dirname, 'main.js' ) ) return importee; + if ( importee === 'foo' ) return path.resolve( __dirname, 'bar.js' ); - return false; - } + return false; + } + }] }, exports: function ( exports ) { assert.strictEqual( exports.path, require( 'path' ) ); diff --git a/test/function/does-not-hang-on-missing-module/_config.js b/test/function/does-not-hang-on-missing-module/_config.js index afcdbcc..f5b0cfa 100644 --- a/test/function/does-not-hang-on-missing-module/_config.js +++ b/test/function/does-not-hang-on-missing-module/_config.js @@ -2,7 +2,12 @@ var assert = require( 'assert' ); module.exports = { description: 'does not hang on missing module (#53)', - error: function ( error ) { - assert.ok( /Could not find package unlessYouCreatedThisFileForSomeReason/.test( error.message ) ); + options: { + onwarn: function ( msg ) { + assert.equal( "Treating 'unlessYouCreatedThisFileForSomeReason' as external dependency", msg ); + } + }, + runtimeError: function ( error ) { + assert.equal( "Cannot find module 'unlessYouCreatedThisFileForSomeReason'", error.message ); } }; diff --git a/test/function/import-from-external-subdirectory/_config.js b/test/function/import-from-external-subdirectory/_config.js deleted file mode 100644 index 57a682c..0000000 --- a/test/function/import-from-external-subdirectory/_config.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - description: 'default resolver imports from a subdirectory of an external module', - babel: true -}; diff --git a/test/function/import-from-external-subdirectory/main.js b/test/function/import-from-external-subdirectory/main.js deleted file mode 100644 index 966ed65..0000000 --- a/test/function/import-from-external-subdirectory/main.js +++ /dev/null @@ -1,5 +0,0 @@ -// this test is brittle, it relies on this dependency continuing -// to be structured in a certain way -import btoa from 'magic-string/src/utils/btoa'; - -assert.equal( btoa( 'it works' ), new Buffer( 'it works' ).toString( 'base64' ) ); diff --git a/test/function/uses-supplied-ast/_config.js b/test/function/uses-supplied-ast/_config.js index fff6bd6..3a35833 100644 --- a/test/function/uses-supplied-ast/_config.js +++ b/test/function/uses-supplied-ast/_config.js @@ -19,16 +19,18 @@ var modules = { module.exports = { description: 'uses supplied AST', options: { - resolveId: function ( importee, importer ) { - if ( !importer ) return 'main'; - return importee; - }, - load: function ( id ) { - if ( id === 'bar' ) { - throw new Error( 'loaded incorrect module' ); - } + plugins: [{ + resolveId: function ( importee, importer ) { + if ( !importer ) return 'main'; + return importee; + }, + load: function ( id ) { + if ( id === 'bar' ) { + throw new Error( 'loaded incorrect module' ); + } - return modules[ id ]; - } + return modules[ id ]; + } + }] } };