-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b8514a
commit 26ced57
Showing
17 changed files
with
209 additions
and
155 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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"exclude": ["*commonjsHelpers.js", "test"], | ||
"exclude": ["test"], | ||
"extension": [".ts", ""] | ||
} |
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
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
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
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
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
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
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,76 @@ | ||
const fixturify = require('fixturify'); | ||
const { basename, resolve } = require('path'); | ||
const { rollup } = require('../../dist/rollup.browser.js'); | ||
const { assertFilesAreEqual, runTestSuiteWithSamples, compareError } = require('../utils.js'); | ||
|
||
runTestSuiteWithSamples('browser', resolve(__dirname, 'samples'), (dir, config) => { | ||
(config.skip ? it.skip : config.solo ? it.only : it)( | ||
basename(dir) + ': ' + config.description, | ||
async () => { | ||
let bundle; | ||
try { | ||
bundle = await rollup({ | ||
input: 'main', | ||
onwarn: warning => { | ||
if (!(config.expectedWarnings && config.expectedWarnings.indexOf(warning.code) >= 0)) { | ||
throw new Error( | ||
`Unexpected warnings (${warning.code}): ${warning.message}\n` + | ||
'If you expect warnings, list their codes in config.expectedWarnings' | ||
); | ||
} | ||
}, | ||
strictDeprecations: true, | ||
...config.options | ||
}); | ||
} catch (error) { | ||
if (config.error) { | ||
compareError(error, config.error); | ||
return; | ||
} else { | ||
throw error; | ||
} | ||
} | ||
if (config.error) { | ||
throw new Error('Expected an error while rolling up'); | ||
} | ||
let output; | ||
try { | ||
({ output } = await bundle.generate({ | ||
exports: 'auto', | ||
format: 'es', | ||
...(config.options || {}).output | ||
})); | ||
} catch (error) { | ||
if (config.generateError) { | ||
compareError(error, config.generateError); | ||
return; | ||
} else { | ||
throw error; | ||
} | ||
} | ||
if (config.generateError) { | ||
throw new Error('Expected an error while generating output'); | ||
} | ||
assertOutputMatches(output, dir); | ||
} | ||
); | ||
}); | ||
|
||
function assertOutputMatches(output, dir) { | ||
const actual = {}; | ||
for (const file of output) { | ||
const filePath = file.fileName.split('/'); | ||
const fileName = filePath.pop(); | ||
let currentDir = actual; | ||
for (const pathElement of filePath) { | ||
if (!currentDir[pathElement]) { | ||
currentDir[pathElement] = {}; | ||
} | ||
currentDir = currentDir[pathElement] = currentDir[pathElement] || {}; | ||
} | ||
currentDir[fileName] = file.source || file.code; | ||
} | ||
fixturify.writeSync(resolve(dir, '_actual'), actual); | ||
const expected = fixturify.readSync(resolve(dir, '_expected')); | ||
assertFilesAreEqual(actual, expected); | ||
} |
This file was deleted.
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
Oops, something went wrong.