Files
react-native/packages/babel-plugin-inline-view-configs/__tests__/index-test.js
T
Andrew Coates (REDMOND) 5b267091ed More consistent snapshots on windows (#28482)
Summary:
Get jest tests to be runnable on windows, and match current snapshots

## Changelog

[Internal] [Fixed] - More consistent snapshots on windows
Pull Request resolved: https://github.com/facebook/react-native/pull/28482

Test Plan: run `yarn test` on a windows machine, and hit the test_windows circleci tests

Reviewed By: hramos

Differential Revision: D20799002

Pulled By: cpojer

fbshipit-source-id: da3db0171c34a43199c7d3dc17b622b37bc91701
2020-04-01 15:10:41 -07:00

50 lines
1.4 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails oncall+react_native
* @format
*/
'use strict';
const {transform: babelTransform} = require('@babel/core');
const fixtures = require('../__test_fixtures__/fixtures.js');
const failures = require('../__test_fixtures__/failures.js');
const transform = (fixture, filename) =>
babelTransform(fixture, {
babelrc: false,
cwd: '/',
filename: filename,
highlightCode: false,
plugins: [require('@babel/plugin-syntax-flow'), require('../index')],
}).code;
describe('Babel plugin inline view configs', () => {
Object.keys(fixtures)
.sort()
.forEach(fixtureName => {
it(`can inline config for ${fixtureName}`, () => {
expect(transform(fixtures[fixtureName], fixtureName)).toMatchSnapshot();
});
});
Object.keys(failures)
.sort()
.forEach(fixtureName => {
it(`fails on inline config for ${fixtureName}`, () => {
expect(() => {
try {
transform(failures[fixtureName], fixtureName);
} catch (err) {
err.message = err.message.replace(/^[A-z]:\\/g, '/'); // Ensure platform consistent snapshots.
throw err;
}
}).toThrowErrorMatchingSnapshot();
});
});
});