marko/test/compiler/vdom.test.js
Michael Rawlings 92c448f639 Autotest refactor (#1023)
* update autotest api and first few test suites

* refactor components-browser to use the new autotest api

* minor changes to update adjustIndent and components-pages to new autotest api

* refactor and combine async-render, deprecated-async-fragments, and render suites

* migrate compiler tests to new autotest runner

* migrate components-compilation tests to use new autotest api

* migrate most remaining test runners to new autotest api

* update adjustIndent

* migrate express tests to new autotest api

* switch from compare to snapshot

* move versions into directory

* remove snapshot sequences, prefix to name, suffix to ext

* refactor autotest

* keep node 4 happy: don't use destructured parameters

* use strict

* update contributing document to reflect new autotest api

* better snapshot errors with clickable path

* remove old vdomSkip property, fix some normalization in the render test runner, skip only tests that need to be skipped

* for generated vdom expectations use expected.html instead of rerendering the html template, update expected files that had editor added newlines at the end

* remove half-finished test that was intended to replace another test (render/fixtures/preserveWhitespace-load-option) - we'll keep the original
2018-03-23 11:27:52 -07:00

62 lines
1.6 KiB
JavaScript

"use strict";
require("../__util__/test-init");
var chai = require("chai");
chai.config.includeStack = true;
var compiler = require("../../compiler");
var autotest = require("../autotest");
var fs = require("fs");
autotest("fixtures-vdom", fixture => {
let test = fixture.test;
let resolve = fixture.resolve;
let snapshot = fixture.snapshot;
test(done => {
var templatePath = resolve("template.marko");
var mainPath = resolve("test.js");
var main;
if (fs.existsSync(mainPath)) {
main = require(mainPath);
}
var compilerOptions = {
writeVersionComment: false,
autoKeyEnabled: true
};
if (main && main.checkError) {
var e;
try {
compiler.compileFileForBrowser(templatePath, compilerOptions);
} catch (_e) {
e = _e;
}
if (!e) {
throw new Error("Error expected");
}
main.checkError(e);
done();
} else {
var compiledTemplate = compiler.compileFileForBrowser(
templatePath,
Object.assign(compilerOptions, main && main.compilerOptions)
);
if (main && main.checkTemplate) {
main.checkTemplate(compiledTemplate);
} else {
var actualSrc = compiledTemplate.code;
actualSrc = actualSrc.replace(/marko\/dist\//g, "marko/src/");
snapshot(actualSrc, ".js");
}
done();
}
});
});