mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Make Flow Parser snapshots more readable
Summary: The Flow Parser's snapshots, which are serializations of the CodegenSchema object, are extremely difficult to read. In this diff, I explicitly serialized the schema objects using Node's `util.inspect`. **Benefits:** - The snapshots are more readable now. - You can copy-paste the objects from the snapshot files directly into the Chrome console, or into other JavaScript files. This is a very useful feature, when we're testing the generators, or other infra that depends on the codegen. Changelog: [Internal] Reviewed By: hramos Differential Revision: D24063112 fbshipit-source-id: 2c6ec3424aac8bab2688dc6ae286b73f90e4bef1
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5a1ca38305
commit
0a2e0f777b
+6933
-7759
File diff suppressed because it is too large
Load Diff
Vendored
+7
-1
@@ -14,6 +14,7 @@
|
||||
const FlowParser = require('../../index.js');
|
||||
const fixtures = require('../__test_fixtures__/fixtures.js');
|
||||
const failureFixtures = require('../__test_fixtures__/failures.js');
|
||||
const util = require('util');
|
||||
jest.mock('fs', () => ({
|
||||
readFileSync: filename => fixtures[filename] || failureFixtures[filename],
|
||||
}));
|
||||
@@ -23,7 +24,12 @@ describe('RN Codegen Flow Parser', () => {
|
||||
.sort()
|
||||
.forEach(fixtureName => {
|
||||
it(`can generate fixture ${fixtureName}`, () => {
|
||||
expect(FlowParser.parseFile(fixtureName)).toMatchSnapshot();
|
||||
const schema = FlowParser.parseFile(fixtureName);
|
||||
const serializedSchema = util.inspect(schema, {
|
||||
showHidden: false,
|
||||
depth: null,
|
||||
});
|
||||
expect(serializedSchema).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+1101
-1238
File diff suppressed because it is too large
Load Diff
Vendored
+8
-1
@@ -14,6 +14,7 @@
|
||||
const FlowParser = require('../../index.js');
|
||||
const fixtures = require('../__test_fixtures__/fixtures.js');
|
||||
const failureFixtures = require('../__test_fixtures__/failures.js');
|
||||
const util = require('util');
|
||||
jest.mock('fs', () => ({
|
||||
readFileSync: filename => fixtures[filename] || failureFixtures[filename],
|
||||
}));
|
||||
@@ -23,7 +24,13 @@ describe('RN Codegen Flow Parser', () => {
|
||||
.sort()
|
||||
.forEach(fixtureName => {
|
||||
it(`can generate fixture ${fixtureName}`, () => {
|
||||
expect(FlowParser.parseModuleFixture(fixtureName)).toMatchSnapshot();
|
||||
const schema = FlowParser.parseModuleFixture(fixtureName);
|
||||
const serializedSchema = util.inspect(schema, {
|
||||
showHidden: false,
|
||||
depth: null,
|
||||
});
|
||||
|
||||
expect(serializedSchema).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user