Browse Source

jest works without babelrc

Daniel Zlotin 7 years ago
parent
commit
41d085aed0
3 changed files with 24 additions and 7 deletions
  1. 0
    5
      .babelrc
  2. 11
    2
      package.json
  3. 13
    0
      src2/env.test.js

+ 0
- 5
.babelrc View File

@@ -1,5 +0,0 @@
1
-{
2
-  "presets": [
3
-    "react-native"
4
-  ]
5
-}

+ 11
- 2
package.json View File

@@ -21,12 +21,12 @@
21 21
   "scripts": {
22 22
     "build": ":",
23 23
     "lint": "eslint src2",
24
-    "test:js": "jest --coverage",
24
+    "test:js": "BABEL_ENV=test jest --coverage",
25 25
     "test:android": "cd android && ./gradlew clean testDebugUnitTest",
26 26
     "test:ios": ":",
27 27
     "pretest": "npm run lint",
28 28
     "test": "npm run test:js && npm run test:android && npm run test:ios",
29
-    "test:watch": "jest --coverage --watch",
29
+    "test:watch": "BABEL_ENV=test jest --coverage --watch",
30 30
     "release": ": #npm version prerelease && npm publish --tag next && npm view react-native-navigation dist-tags && git push"
31 31
   },
32 32
   "peerDependencies": {
@@ -53,6 +53,15 @@
53 53
     "jest-cli": "17.x.x",
54 54
     "react-test-renderer": "15.4.1"
55 55
   },
56
+  "babel": {
57
+    "env": {
58
+      "test": {
59
+        "presets": [
60
+          "react-native"
61
+        ]
62
+      }
63
+    }
64
+  },
56 65
   "jest": {
57 66
     "preset": "react-native",
58 67
     "testPathDirs": [

+ 13
- 0
src2/env.test.js View File

@@ -0,0 +1,13 @@
1
+describe('test environment', () => {
2
+  it('handles object spread', () => {
3
+    const {x, y, ...z} = {x: 1, y: 2, a: 3, b: 4};
4
+    expect(x).toEqual(1);
5
+    expect(y).toEqual(2);
6
+    expect(z).toEqual({a: 3, b: 4});
7
+  });
8
+
9
+  it('handles async await', async() => {
10
+    const result = await new Promise((r) => r('hello'));
11
+    expect(result).toEqual('hello');
12
+  });
13
+});