fix path by url
diff --git a/test/index.html b/test/index.html
index 1c935bc..87c2ff8 100644
--- a/test/index.html
+++ b/test/index.html
@@ -31,6 +31,18 @@
<body>
<div id="lottie"></div>
<script>
+ const buildRenderSettings = (searchParams) => {
+ const defaultValues = {
+ path: '/test/animations/adrock.json',
+ };
+ searchParams.forEach((value, key) => {
+ defaultValues[key] = value;
+ });
+
+ return defaultValues;
+ };
+</script>
+<script>
const submitAndWaitForResponse = (currentFrame, isLast) => (
new Promise((resolve) => {
window.onMessageReceivedEvent({
@@ -50,11 +62,14 @@
</script>
<script>
- const url = new URL(window.location);
window.startProcess = () => {
+ const url = new URL(window.location);
+ const settings = buildRenderSettings(url.searchParams)
const animation = lottie.loadAnimation({
container: document.getElementById('lottie'),
- path: url.searchParams.path || '/test/animations/adrock.json'
+ path: settings.path,
+ autoplay: false,
+ loop: false,
})
animation.addEventListener('DOMLoaded', async () => {
window.onAnimationLoaded();
diff --git a/test/index.js b/test/index.js
index 68f7e8b..7c24769 100644
--- a/test/index.js
+++ b/test/index.js
@@ -12,7 +12,7 @@
const PNG = require('pngjs').PNG;
const pixelmatch = require('pixelmatch');
-const examplesDirectory = './test/animations/';
+const examplesDirectory = '/test/animations/';
const createDirectory = 'screenshots/create';
const compareDirectory = 'screenshots/compare';
@@ -46,7 +46,6 @@
...defaultValues,
...commandLineArgs(opts),
};
- console.log('settings', settings);
return settings;
};
@@ -87,7 +86,6 @@
const startServer = async () => {
const app = express();
await Promise.all(filesData.map(async (file) => {
- console.log('FILE', file);
const fileData = await readFile(file.filePath, getEncoding(file.type));
app.get(file.path, async (req, res) => {
res.writeHead(200, getContentTypeHeader(file.type));
@@ -225,7 +223,7 @@
}
const iteratePages = async (browser, settings) => {
- const files = await getDirFiles(examplesDirectory);
+ const files = await getDirFiles('.' + examplesDirectory);
const jsonFiles = files.filter((file) => file.indexOf('.json') !== -1);
const failedAnimations = [];
for (let i = 0; i < jsonFiles.length; i += 1) {