0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-27 09:50:52 -05:00

added support for example versioning in tests

This commit is contained in:
liabru 2020-12-30 23:03:38 +00:00
parent 07927162fc
commit 31d0ace631
2 changed files with 17 additions and 2 deletions

View file

@ -5,9 +5,16 @@ jest.setTimeout(120 * 1000);
const puppeteer = require('puppeteer-core'); const puppeteer = require('puppeteer-core');
const Example = require('../examples/index'); const Example = require('../examples/index');
const MatterBuild = require('../build/matter');
const { versionSatisfies } = require('../src/core/Plugin');
const fs = require('fs'); const fs = require('fs');
const examples = Object.keys(Example); const examples = Object.keys(Example).filter(key => {
const buildVersion = MatterBuild.version;
const exampleFor = Example[key].for;
return versionSatisfies(buildVersion, exampleFor);
});
const browserPath = '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'; const browserPath = '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome';
const demoPagePath = 'http://localhost:8000/'; const demoPagePath = 'http://localhost:8000/';
const totalUpdates = 5; const totalUpdates = 5;

View file

@ -7,13 +7,21 @@ const { comparisonReport, toMatchExtrinsics, toMatchIntrinsics } = require('./Te
const Example = require('../examples/index'); const Example = require('../examples/index');
const MatterBuild = require('../build/matter'); const MatterBuild = require('../build/matter');
const { versionSatisfies } = require('../src/core/Plugin');
const Worker = require('jest-worker').default; const Worker = require('jest-worker').default;
const testComparison = process.env.COMPARE === 'true'; const testComparison = process.env.COMPARE === 'true';
const saveComparison = process.env.SAVE === 'true'; const saveComparison = process.env.SAVE === 'true';
const excludeExamples = ['svg', 'terrain']; const excludeExamples = ['svg', 'terrain'];
const excludeJitter = ['stack', 'circleStack', 'restitution', 'staticFriction', 'friction', 'newtonsCradle', 'catapult']; const excludeJitter = ['stack', 'circleStack', 'restitution', 'staticFriction', 'friction', 'newtonsCradle', 'catapult'];
const examples = Object.keys(Example).filter(key => !excludeExamples.includes(key));
const examples = Object.keys(Example).filter(key => {
const excluded = excludeExamples.includes(key);
const buildVersion = MatterBuild.version;
const exampleFor = Example[key].for;
const supported = versionSatisfies(buildVersion, exampleFor);
return !excluded && supported;
});
const runExamples = async useDev => { const runExamples = async useDev => {
const worker = new Worker(require.resolve('./ExampleWorker'), { const worker = new Worker(require.resolve('./ExampleWorker'), {