@ -32,30 +32,17 @@ const { test, run } = suite<CssTest>(async (config, cwd) => {
await compile_directory ( cwd , 'client' , { cssHash : ( ) = > 'svelte-xyz' , . . . config . compileOptions } ) ;
await compile_directory ( cwd , 'client' , { cssHash : ( ) = > 'svelte-xyz' , . . . config . compileOptions } ) ;
await compile_directory ( cwd , 'server' , { cssHash : ( ) = > 'svelte-xyz' , . . . config . compileOptions } ) ;
await compile_directory ( cwd , 'server' , { cssHash : ( ) = > 'svelte-xyz' , . . . config . compileOptions } ) ;
const dom_css = fs . readFileSync ( ` ${ cwd } /_output/client/input.svelte.css ` , 'utf-8' ) . trim ( ) ;
const ssr_css = fs . readFileSync ( ` ${ cwd } /_output/server/input.svelte.css ` , 'utf-8' ) . trim ( ) ;
assert . equal ( dom_css , ssr_css ) ;
const dom_warnings = load_warnings ( ` ${ cwd } /_output/client/input.svelte.warnings.json ` ) ;
const ssr_warnings = load_warnings ( ` ${ cwd } /_output/server/input.svelte.warnings.json ` ) ;
const expected_warnings = ( config . warnings || [ ] ) . map ( normalize_warning ) ;
assert . deepEqual ( dom_warnings , ssr_warnings ) ;
assert . deepEqual ( dom_warnings . map ( normalize_warning ) , expected_warnings ) ;
const expected = {
const expected = {
html : try_read_file ( ` ${ cwd } /expected.html ` ) ,
html : try_read_file ( ` ${ cwd } /expected.html ` ) ,
css : try_read_file ( ` ${ cwd } /expected.css ` )
css : try_read_file ( ` ${ cwd } /expected.css ` )
} ;
} ;
assert . equal ( dom_css . trim ( ) . replace ( /\r\n/g , '\n' ) , ( expected . css ? ? '' ) . trim ( ) ) ;
// we do this here, rather than in the expected.html !== null
// we do this here, rather than in the expected.html !== null
// block, to verify that valid code was generated
// block, to verify that valid code was generated
const ClientComponent = ( await import ( ` ${ cwd } /_output/client/input.svelte.js ` ) ) . default ;
const ClientComponent = ( await import ( ` ${ cwd } /_output/client/input.svelte.js ` ) ) . default ;
const ServerComponent = ( await import ( ` ${ cwd } /_output/server/input.svelte.js ` ) ) . default ;
const ServerComponent = ( await import ( ` ${ cwd } /_output/server/input.svelte.js ` ) ) . default ;
// verify that the right elements have scoping selectors
// verify that the right elements have scoping selectors (do this first to ensure all actual files are written to disk)
if ( expected . html !== null ) {
if ( expected . html !== null ) {
const target = window . document . createElement ( 'main' ) ;
const target = window . document . createElement ( 'main' ) ;
@ -75,6 +62,19 @@ const { test, run } = suite<CssTest>(async (config, cwd) => {
// const actual_ssr = ServerComponent.render(config.props).html;
// const actual_ssr = ServerComponent.render(config.props).html;
// assert_html_equal(actual_ssr, expected.html);
// assert_html_equal(actual_ssr, expected.html);
}
}
const dom_css = fs . readFileSync ( ` ${ cwd } /_output/client/input.svelte.css ` , 'utf-8' ) . trim ( ) ;
const ssr_css = fs . readFileSync ( ` ${ cwd } /_output/server/input.svelte.css ` , 'utf-8' ) . trim ( ) ;
assert . equal ( dom_css , ssr_css ) ;
const dom_warnings = load_warnings ( ` ${ cwd } /_output/client/input.svelte.warnings.json ` ) ;
const ssr_warnings = load_warnings ( ` ${ cwd } /_output/server/input.svelte.warnings.json ` ) ;
const expected_warnings = ( config . warnings || [ ] ) . map ( normalize_warning ) ;
assert . deepEqual ( dom_warnings , ssr_warnings ) ;
assert . deepEqual ( dom_warnings . map ( normalize_warning ) , expected_warnings ) ;
assert . equal ( dom_css . trim ( ) . replace ( /\r\n/g , '\n' ) , ( expected . css ? ? '' ) . trim ( ) ) ;
} ) ;
} ) ;
export { test } ;
export { test } ;