diff --git a/gentest/gentest.rb b/gentest/gentest.rb
index 54481ac3..05f27bbb 100644
--- a/gentest/gentest.rb
+++ b/gentest/gentest.rb
@@ -56,7 +56,7 @@ Dir['fixtures/*.html'].each do |file|
print logs[4]
- f = File.open("../javascript/tests/Facebook.Yoga/#{name}.js", 'w')
+ f = File.open("../javascript/tests/generated/#{name}.test.js", 'w')
f.write eval(logs[3].message.sub(/^[^"]*/, '')).sub('YogaTest', name)
f.close
end
diff --git a/javascript/README.md b/javascript/README.md
index 952b1323..02c616bb 100644
--- a/javascript/README.md
+++ b/javascript/README.md
@@ -37,7 +37,12 @@ import { loadYoga } from "yoga-layout/entrypoint/wasm-async";
## Contributing
-`yoga-layout` may be locally built by running the following set of commands. The build requires that some dependencies be installed first.
+### Requirements
+
+1. CMake >= 3.13
+1. (Optional) ninja, for faster builds
+
+### Building
```bash
git clone https://github.com/facebook/yoga.git
@@ -46,7 +51,12 @@ yarn install
yarn build
```
-### Requirements
+### Testing
-1. CMake >= 3.13
-1. (Optional) ninja, for faster builds
+```bash
+# Build and test all entrypoints
+yarn test
+
+# Build and test a specific entrypoint
+yarn test:asmjs-sync
+```
diff --git a/javascript/jest.config.js b/javascript/jest.config.js
index 2e962810..80ef40ac 100644
--- a/javascript/jest.config.js
+++ b/javascript/jest.config.js
@@ -9,6 +9,6 @@
module.exports = {
setupFiles: ["./jest.setup.js", "./tests/tools.js"],
- testRegex: '/tests/Facebook.Yoga/.*\\.js$',
+ testRegex: '/tests/.*\\.test\\.js$',
watchman: false,
}
diff --git a/javascript/package.json b/javascript/package.json
index 3fb85e6d..aa68f1e8 100644
--- a/javascript/package.json
+++ b/javascript/package.json
@@ -26,17 +26,17 @@
"src_js/**"
],
"scripts": {
- "benchmark": "node tests/run-bench $(find tests/Benchmarks -name '*.js')",
- "build": "yarn build:native && yarn build:js",
+ "benchmark": "yarn build && node tests/run-bench $(find tests/benchmarks -name '*.js')",
+ "build": "yarn build:js && yarn build:native",
"build:configure": "which ninja && emcmake cmake -S . -B build -G Ninja || emcmake cmake -S . -B build",
"build:copy-dts": "cd src_js && find . -name '*.d.ts' | cpio -pdm ../dist",
"build:js": "babel src_js --source-maps --out-dir dist && yarn build:copy-dts",
"build:native": "yarn build:configure && cmake --build build",
- "test": "yarn test:asmjs && yarn test:asmjs-sync && yarn test:wasm && yarn test:wasm-sync",
- "test:asmjs": "WASM=0 SYNC=0 jest",
- "test:asmjs-sync": "WASM=0 SYNC=1 jest",
- "test:wasm": "WASM=1 SYNC=0 jest",
- "test:wasm-sync": "WASM=1 SYNC=1 jest"
+ "test": "yarn test:asmjs-async && yarn test:asmjs-sync && yarn test:wasm-async && yarn test:wasm-sync",
+ "test:asmjs-async": "yarn build --target asmjs-async && WASM=0 SYNC=0 jest",
+ "test:asmjs-sync": "yarn build --target asmjs-sync && WASM=0 SYNC=1 jest",
+ "test:wasm-async": "yarn build --target wasm-async && WASM=1 SYNC=0 jest",
+ "test:wasm-sync": "yarn build --target wasm-sync && WASM=1 SYNC=1 jest"
},
"devDependencies": {
"@babel/cli": "^7.20.7",
diff --git a/javascript/src_js/entrypoint/_entryAsync.js b/javascript/src_js/entrypoint/_entryAsync.js
index f9957efa..8cb98a65 100644
--- a/javascript/src_js/entrypoint/_entryAsync.js
+++ b/javascript/src_js/entrypoint/_entryAsync.js
@@ -7,9 +7,9 @@
* @format
*/
-const wrapAsm = require('./wrapAsm');
+const wrapAsm = require('../wrapAsm');
module.exports = (loadAsm) => ({
loadYoga: () => loadAsm().then(wrapAsm),
- ...require('./generated/YGEnums'),
+ ...require('../generated/YGEnums'),
});
diff --git a/javascript/src_js/entrypoint/_entrySync.js b/javascript/src_js/entrypoint/_entrySync.js
index b1cfe71c..ae399bbc 100644
--- a/javascript/src_js/entrypoint/_entrySync.js
+++ b/javascript/src_js/entrypoint/_entrySync.js
@@ -7,5 +7,5 @@
* @format
*/
- const wrapAsm = require('./wrapAsm');
+ const wrapAsm = require('../wrapAsm');
module.exports = (asm) => wrapAsm(asm());
diff --git a/javascript/src_js/entrypoint/asmjs-async.js b/javascript/src_js/entrypoint/asmjs-async.js
index 11c686cc..7ca8b3e1 100644
--- a/javascript/src_js/entrypoint/asmjs-async.js
+++ b/javascript/src_js/entrypoint/asmjs-async.js
@@ -8,4 +8,4 @@
*/
const asm = require('../build/asmjs-async');
-module.exports = require("./entryAsync")(asm);
+module.exports = require("./_entryAsync")(asm);
diff --git a/javascript/src_js/entrypoint/asmjs-sync.js b/javascript/src_js/entrypoint/asmjs-sync.js
index c165bad9..b9ff595f 100644
--- a/javascript/src_js/entrypoint/asmjs-sync.js
+++ b/javascript/src_js/entrypoint/asmjs-sync.js
@@ -8,4 +8,4 @@
*/
const asm = require('../build/asmjs-sync');
-module.exports = require("./entrySync")(asm);
+module.exports = require("./_entrySync")(asm);
diff --git a/javascript/src_js/entrypoint/wasm-async.js b/javascript/src_js/entrypoint/wasm-async.js
index c3a821ea..49d246df 100644
--- a/javascript/src_js/entrypoint/wasm-async.js
+++ b/javascript/src_js/entrypoint/wasm-async.js
@@ -8,4 +8,4 @@
*/
const asm = require('../build/wasm-async');
-module.exports = require("./entryAsync")(asm);
+module.exports = require("./_entryAsync")(asm);
diff --git a/javascript/src_js/entrypoint/wasm-sync.js b/javascript/src_js/entrypoint/wasm-sync.js
index 1c46a942..08621891 100644
--- a/javascript/src_js/entrypoint/wasm-sync.js
+++ b/javascript/src_js/entrypoint/wasm-sync.js
@@ -8,4 +8,4 @@
*/
const asm = require('../build/wasm-sync');
-module.exports = require("./entrySync")(asm);
+module.exports = require("./_entrySync")(asm);
diff --git a/javascript/tests/Benchmarks/YGBenchmark.js b/javascript/tests/Benchmarks/YGBenchmark.test.js
similarity index 96%
rename from javascript/tests/Benchmarks/YGBenchmark.js
rename to javascript/tests/Benchmarks/YGBenchmark.test.js
index 296cd365..0ac24814 100644
--- a/javascript/tests/Benchmarks/YGBenchmark.js
+++ b/javascript/tests/Benchmarks/YGBenchmark.test.js
@@ -5,9 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
-var Yoga = Yoga || require("../../dist/entry-" + process.env.TEST_ENTRY);
-
-var ITERATIONS = 2000;
+const ITERATIONS = 2000;
+const YGBENCHMARK = global.YGBENCHMARK ?? global.test;
YGBENCHMARK("Stack with flex", function() {
var root = Yoga.Node.create();
diff --git a/javascript/tests/Facebook.Yoga/YGAlignBaselineTest.js b/javascript/tests/YGAlignBaselineTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGAlignBaselineTest.js
rename to javascript/tests/YGAlignBaselineTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGComputedBorderTest.js b/javascript/tests/YGComputedBorderTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGComputedBorderTest.js
rename to javascript/tests/YGComputedBorderTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGComputedMarginTest.js b/javascript/tests/YGComputedMarginTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGComputedMarginTest.js
rename to javascript/tests/YGComputedMarginTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGComputedPaddingTest.js b/javascript/tests/YGComputedPaddingTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGComputedPaddingTest.js
rename to javascript/tests/YGComputedPaddingTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGDirtiedTest.js b/javascript/tests/YGDirtiedTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGDirtiedTest.js
rename to javascript/tests/YGDirtiedTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGMeasureCacheTest.js b/javascript/tests/YGMeasureCacheTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGMeasureCacheTest.js
rename to javascript/tests/YGMeasureCacheTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGMeasureTest.js b/javascript/tests/YGMeasureTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGMeasureTest.js
rename to javascript/tests/YGMeasureTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGAbsolutePositionTest.js b/javascript/tests/generated/YGAbsolutePositionTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGAbsolutePositionTest.js
rename to javascript/tests/generated/YGAbsolutePositionTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGAlignContentTest.js b/javascript/tests/generated/YGAlignContentTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGAlignContentTest.js
rename to javascript/tests/generated/YGAlignContentTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGAlignItemsTest.js b/javascript/tests/generated/YGAlignItemsTest.test.js
similarity index 99%
rename from javascript/tests/Facebook.Yoga/YGAlignItemsTest.js
rename to javascript/tests/generated/YGAlignItemsTest.test.js
index be25bd46..8f92afec 100644
--- a/javascript/tests/Facebook.Yoga/YGAlignItemsTest.js
+++ b/javascript/tests/generated/YGAlignItemsTest.test.js
@@ -1361,7 +1361,7 @@ it("align_baseline_multiline_column", function () {
console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
- console.assert(70 === root_child1.getComputedLeft(), "70 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(50 === root_child1.getComputedLeft(), "50 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
console.assert(30 === root_child1.getComputedWidth(), "30 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
@@ -1371,7 +1371,7 @@ it("align_baseline_multiline_column", function () {
console.assert(20 === root_child1_child0.getComputedWidth(), "20 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
console.assert(20 === root_child1_child0.getComputedHeight(), "20 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")");
- console.assert(10 === root_child2.getComputedLeft(), "10 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
+ console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
console.assert(40 === root_child2.getComputedWidth(), "40 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
console.assert(70 === root_child2.getComputedHeight(), "70 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
@@ -1481,7 +1481,7 @@ it("align_baseline_multiline_column2", function () {
console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
- console.assert(70 === root_child1.getComputedLeft(), "70 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(50 === root_child1.getComputedLeft(), "50 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
console.assert(30 === root_child1.getComputedWidth(), "30 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
@@ -1491,7 +1491,7 @@ it("align_baseline_multiline_column2", function () {
console.assert(20 === root_child1_child0.getComputedWidth(), "20 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
console.assert(20 === root_child1_child0.getComputedHeight(), "20 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")");
- console.assert(10 === root_child2.getComputedLeft(), "10 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
+ console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
console.assert(40 === root_child2.getComputedWidth(), "40 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
console.assert(70 === root_child2.getComputedHeight(), "70 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
diff --git a/javascript/tests/Facebook.Yoga/YGAlignSelfTest.js b/javascript/tests/generated/YGAlignSelfTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGAlignSelfTest.js
rename to javascript/tests/generated/YGAlignSelfTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGAndroidNewsFeed.js b/javascript/tests/generated/YGAndroidNewsFeed.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGAndroidNewsFeed.js
rename to javascript/tests/generated/YGAndroidNewsFeed.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGBorderTest.js b/javascript/tests/generated/YGBorderTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGBorderTest.js
rename to javascript/tests/generated/YGBorderTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGDimensionTest.js b/javascript/tests/generated/YGDimensionTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGDimensionTest.js
rename to javascript/tests/generated/YGDimensionTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGDisplayTest.js b/javascript/tests/generated/YGDisplayTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGDisplayTest.js
rename to javascript/tests/generated/YGDisplayTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGFlexDirectionTest.js b/javascript/tests/generated/YGFlexDirectionTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGFlexDirectionTest.js
rename to javascript/tests/generated/YGFlexDirectionTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGFlexTest.js b/javascript/tests/generated/YGFlexTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGFlexTest.js
rename to javascript/tests/generated/YGFlexTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGFlexWrapTest.js b/javascript/tests/generated/YGFlexWrapTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGFlexWrapTest.js
rename to javascript/tests/generated/YGFlexWrapTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGGapTest.js b/javascript/tests/generated/YGGapTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGGapTest.js
rename to javascript/tests/generated/YGGapTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGJustifyContentTest.js b/javascript/tests/generated/YGJustifyContentTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGJustifyContentTest.js
rename to javascript/tests/generated/YGJustifyContentTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGMarginTest.js b/javascript/tests/generated/YGMarginTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGMarginTest.js
rename to javascript/tests/generated/YGMarginTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGMinMaxDimensionTest.js b/javascript/tests/generated/YGMinMaxDimensionTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGMinMaxDimensionTest.js
rename to javascript/tests/generated/YGMinMaxDimensionTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGPaddingTest.js b/javascript/tests/generated/YGPaddingTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGPaddingTest.js
rename to javascript/tests/generated/YGPaddingTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGPercentageTest.js b/javascript/tests/generated/YGPercentageTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGPercentageTest.js
rename to javascript/tests/generated/YGPercentageTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGRoundingTest.js b/javascript/tests/generated/YGRoundingTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGRoundingTest.js
rename to javascript/tests/generated/YGRoundingTest.test.js
diff --git a/javascript/tests/Facebook.Yoga/YGSizeOverflowTest.js b/javascript/tests/generated/YGSizeOverflowTest.test.js
similarity index 100%
rename from javascript/tests/Facebook.Yoga/YGSizeOverflowTest.js
rename to javascript/tests/generated/YGSizeOverflowTest.test.js
diff --git a/javascript/tests/index.html b/javascript/tests/index.html
deleted file mode 100644
index dde606d8..00000000
--- a/javascript/tests/index.html
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-