|
|
@ -34,7 +34,7 @@ describe("ssr", () => {
|
|
|
|
// add .solo to a sample directory name to only run that test, or
|
|
|
|
// add .solo to a sample directory name to only run that test, or
|
|
|
|
// .show to always show the output. or both
|
|
|
|
// .show to always show the output. or both
|
|
|
|
const solo = /\.solo/.test(dir);
|
|
|
|
const solo = /\.solo/.test(dir);
|
|
|
|
let show = /\.show/.test(dir);
|
|
|
|
const show = /\.show/.test(dir);
|
|
|
|
|
|
|
|
|
|
|
|
if (solo && process.env.CI) {
|
|
|
|
if (solo && process.env.CI) {
|
|
|
|
throw new Error("Forgot to remove `solo: true` from test");
|
|
|
|
throw new Error("Forgot to remove `solo: true` from test");
|
|
|
@ -42,36 +42,27 @@ describe("ssr", () => {
|
|
|
|
|
|
|
|
|
|
|
|
(solo ? it.only : it)(dir, () => {
|
|
|
|
(solo ? it.only : it)(dir, () => {
|
|
|
|
dir = path.resolve("test/server-side-rendering/samples", dir);
|
|
|
|
dir = path.resolve("test/server-side-rendering/samples", dir);
|
|
|
|
const component = require(`${dir}/main.html`);
|
|
|
|
try {
|
|
|
|
|
|
|
|
const component = require(`${dir}/main.html`);
|
|
|
|
|
|
|
|
|
|
|
|
const expectedHtml = tryToReadFile(`${dir}/_expected.html`);
|
|
|
|
const expectedHtml = tryToReadFile(`${dir}/_expected.html`);
|
|
|
|
const expectedCss = tryToReadFile(`${dir}/_expected.css`) || "";
|
|
|
|
const expectedCss = tryToReadFile(`${dir}/_expected.css`) || "";
|
|
|
|
|
|
|
|
|
|
|
|
const data = tryToLoadJson(`${dir}/data.json`);
|
|
|
|
const data = tryToLoadJson(`${dir}/data.json`);
|
|
|
|
let html;
|
|
|
|
|
|
|
|
let css;
|
|
|
|
|
|
|
|
let error;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
const html = component.render(data);
|
|
|
|
html = component.render(data);
|
|
|
|
const css = component.renderCss().css;
|
|
|
|
css = component.renderCss().css;
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
show = true;
|
|
|
|
|
|
|
|
error = e;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (show) showOutput(dir, { generate: "ssr" });
|
|
|
|
fs.writeFileSync(`${dir}/_actual.html`, html);
|
|
|
|
if (error) throw error;
|
|
|
|
if (css) fs.writeFileSync(`${dir}/_actual.css`, css);
|
|
|
|
|
|
|
|
|
|
|
|
fs.writeFileSync(`${dir}/_actual.html`, html);
|
|
|
|
|
|
|
|
if (css) fs.writeFileSync(`${dir}/_actual.css`, css);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
assert.htmlEqual(html, expectedHtml);
|
|
|
|
assert.htmlEqual(html, expectedHtml);
|
|
|
|
assert.equal(
|
|
|
|
assert.equal(
|
|
|
|
css.replace(/^\s+/gm, ""),
|
|
|
|
css.replace(/^\s+/gm, ""),
|
|
|
|
expectedCss.replace(/^\s+/gm, "")
|
|
|
|
expectedCss.replace(/^\s+/gm, "")
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (show) showOutput(dir, { generate: 'ssr' });
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
showOutput(dir, { generate: 'ssr' });
|
|
|
|
showOutput(dir, { generate: 'ssr' });
|
|
|
|
throw err;
|
|
|
|
throw err;
|
|
|
|