add infrastructure for sourcemap tests

pull/97/head
Rich-Harris 8 years ago
parent 4d186aa1b0
commit 5e8a25fe65

@ -56,6 +56,7 @@
"rollup-plugin-buble": "^0.14.0",
"rollup-plugin-commonjs": "^5.0.5",
"rollup-plugin-node-resolve": "^2.0.0",
"source-map": "^0.5.6",
"source-map-support": "^0.4.6"
},
"nyc": {

@ -0,0 +1,9 @@
{{foo.bar.baz}}
<script>
export default {
onrender () {
console.log( 42 );
}
};
</script>

@ -0,0 +1,7 @@
export function test ( assert, code, map, smc, locator ) {
console.log( `code`, code )
console.log( `map`, map )
let loc = locator( 'foo.bar.baz' );
console.log( `loc`, loc )
}

@ -5,6 +5,8 @@ import * as path from 'path';
import * as fs from 'fs';
import jsdom from 'jsdom';
import * as acorn from 'acorn';
import { SourceMapConsumer } from 'source-map';
import { getLocator } from 'locate-character';
import * as consoleGroup from 'console-group';
consoleGroup.install();
@ -468,4 +470,24 @@ describe( 'svelte', () => {
});
});
});
describe( 'sourcemaps', () => {
fs.readdirSync( 'test/sourcemaps' ).forEach( dir => {
if ( dir[0] === '.' ) return;
const solo = exists( `test/sourcemaps/${dir}/solo` );
( solo ? it.only : it )( dir, () => {
const input = fs.readFileSync( `test/sourcemaps/${dir}/input.html`, 'utf-8' ).replace( /\s+$/, '' );
const { code, map } = svelte.compile( input );
const { test } = require( `./sourcemaps/${dir}/test.js` );
const smc = new SourceMapConsumer( map );
const locator = getLocator( code );
test( assert, code, map, smc, locator );
});
});
});
});

Loading…
Cancel
Save