Compare commits

...
2 Commits
Author SHA1 Message Date
Emin Khateeb af15e006c1 typescript jest files are now working 2018-03-06 22:55:43 +01:00
Emin Khateeb 010c267dfe changed indentation style on tsconfig 2018-03-06 22:24:38 +01:00
5 changed files with 30 additions and 17 deletions

No files matched your search

+1 -4
View File
@@ -19,6 +19,7 @@ node setup.js
- [TypeScript](https://github.com/Microsoft/TypeScript)
- [React Native TypeScript Transformer](https://github.com/ds300/react-native-typescript-transformer)
- [Type definitions for React & React Native](https://github.com/DefinitelyTyped/DefinitelyTyped)
- [TS Jest](https://github.com/kulshekhar/ts-jest)
- [TSLint](https://github.com/palantir/tslint)
- [TSLint React](https://github.com/palantir/tslint-react)
@@ -28,10 +29,6 @@ This template always uses the latest versions of the dependencies at the time wh
The React Native CLI supports automatic installation of production dependencies only. Since TypeScript and the other dependencies are dev dependencies, the setup script is being used to install those. It also takes care of obsolete files like the `.flowconfig` and the `setup.js` itself after the setup.
### What about Jest?
This template does not cover Jest yet. For more info on the current status check the [open issue](https://github.com/emin93/react-native-template-typescript/issues/1).
### How will this template affect the React Native CLI workflow?
The React Native CLI will do everything just as without a template and afterwards overwrite the files with the ones from this template. This means you don't have to worry about incompatibility issues with later React Native upgrades.
+2 -2
View File
@@ -1,9 +1,9 @@
import * as React from "react";
import "react-native";
import renderer from "react-test-renderer";
import { create } from "react-test-renderer";
import App from "../src/App";
it("renders correctly", () => {
const tree = renderer.create(<App exampleProp="helloWorld" />);
const tree = create(<App exampleProp="helloWorld" />);
});
+15
View File
@@ -0,0 +1,15 @@
{
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"modulePaths": ["<rootDir>"]
}
+3 -2
View File
@@ -3,6 +3,7 @@ const path = require('path');
const { execSync } = require('child_process');
const packageJson = require('./package.json');
const jestJson = require('./jest.json');
const devDependencies = require('./devDependencies.json');
const deleteFile = (fileName) => fs.unlinkSync(path.join(process.cwd(), fileName));
@@ -10,16 +11,16 @@ const writeFile = (fileName, data) => fs.writeFileSync(path.join(process.cwd(),
packageJson.scripts.start = `${packageJson.scripts.start} --config ../../../../rn-cli.config.js`;
packageJson.scripts.lint = 'tslint -c tslint.json "src/**/*.{ts,tsx}"';
packageJson.jest = Object.assign(packageJson.jest, jestJson);
writeFile('package.json', JSON.stringify(packageJson, null, 2));
execSync(`npm i ${devDependencies.join(' ')} --save-dev --save-exact`);
execSync(`npm uninstall babel-jest babel-preset-react-native --save`);
deleteFile('App.js');
deleteFile('__tests__/App.js');
deleteFile('.flowconfig');
deleteFile('.babelrc');
deleteFile('devDependencies.json');
deleteFile('jest.json');
deleteFile('README.md');
deleteFile('LICENSE');
deleteFile('setup.js');
+9 -9
View File
@@ -1,11 +1,11 @@
{
"compilerOptions": {
"target": "es2015",
"jsx": "react",
"noEmit": true,
"moduleResolution": "node",
},
"exclude": [
"node_modules"
]
"compilerOptions": {
"target": "es2015",
"jsx": "react",
"noEmit": true,
"moduleResolution": "node",
},
"exclude": [
"node_modules"
]
}