@nx/react-native 16.6.0-beta.6 → 16.6.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react-native",
3
- "version": "16.6.0-beta.6",
3
+ "version": "16.6.0-beta.8",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for React Native contains generators for managing React Native applications and libraries within an Nx workspace. It provides: \n\n-Integration with libraries such as Jest, Detox, and Storybook.\n-Scaffolding for creating buildable libraries that can be published to npm.\n-Utilities for automatic workspace refactoring.",
6
6
  "keywords": [
@@ -25,14 +25,14 @@
25
25
  "main": "./index",
26
26
  "types": "index.d.ts",
27
27
  "dependencies": {
28
- "@nrwl/react-native": "16.6.0-beta.6",
29
- "@nx/detox": "16.6.0-beta.6",
30
- "@nx/devkit": "16.6.0-beta.6",
31
- "@nx/jest": "16.6.0-beta.6",
32
- "@nx/js": "16.6.0-beta.6",
33
- "@nx/linter": "16.6.0-beta.6",
34
- "@nx/react": "16.6.0-beta.6",
35
- "@nx/workspace": "16.6.0-beta.6",
28
+ "@nrwl/react-native": "16.6.0-beta.8",
29
+ "@nx/detox": "16.6.0-beta.8",
30
+ "@nx/devkit": "16.6.0-beta.8",
31
+ "@nx/jest": "16.6.0-beta.8",
32
+ "@nx/js": "16.6.0-beta.8",
33
+ "@nx/linter": "16.6.0-beta.8",
34
+ "@nx/react": "16.6.0-beta.8",
35
+ "@nx/workspace": "16.6.0-beta.8",
36
36
  "chalk": "^4.1.0",
37
37
  "enhanced-resolve": "^5.8.3",
38
38
  "fs-extra": "^11.1.0",
@@ -57,5 +57,5 @@
57
57
  "publishConfig": {
58
58
  "access": "public"
59
59
  },
60
- "gitHead": "9aad21dbfb2b659e488b6626f59df58ab23c0032"
60
+ "gitHead": "d1d06349e703d903ac47fb7adc7d250ce140d77e"
61
61
  }
@@ -60,6 +60,21 @@ describe('app', () => {
60
60
  expect(tsconfig.extends).toEqual('../../tsconfig.base.json');
61
61
 
62
62
  expect(appTree.exists('apps/my-app/.eslintrc.json')).toBe(true);
63
+ expect(appTree.read('apps/my-app/jest.config.ts', 'utf-8'))
64
+ .toMatchInlineSnapshot(`
65
+ "module.exports = {
66
+ displayName: 'my-app',
67
+ preset: 'react-native',
68
+ resolver: '@nx/jest/plugins/resolver',
69
+ moduleFileExtensions: ['ts', 'js', 'html', 'tsx', 'jsx'],
70
+ setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
71
+ moduleNameMapper: {
72
+ '\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock',
73
+ },
74
+ coverageDirectory: '../../coverage/apps/my-app',
75
+ };
76
+ "
77
+ `);
63
78
  });
64
79
 
65
80
  it('should generate targets', async () => {
@@ -71,7 +86,6 @@ describe('app', () => {
71
86
  install: false,
72
87
  });
73
88
  const targets = readProjectConfiguration(appTree, 'my-app').targets;
74
- console.log(targets.test);
75
89
  expect(targets.test).toBeDefined();
76
90
  });
77
91
 
@@ -242,6 +242,72 @@ describe('lib', () => {
242
242
  outputs: ['{options.outputFile}'],
243
243
  });
244
244
  });
245
+
246
+ it('should generate test configuration', async () => {
247
+ await libraryGenerator(appTree, {
248
+ ...defaultSchema,
249
+ unitTestRunner: 'jest',
250
+ });
251
+
252
+ expect(appTree.read('libs/my-lib/tsconfig.spec.json', 'utf-8'))
253
+ .toMatchInlineSnapshot(`
254
+ "{
255
+ "extends": "./tsconfig.json",
256
+ "compilerOptions": {
257
+ "outDir": "../../dist/out-tsc",
258
+ "module": "commonjs",
259
+ "types": ["jest", "node"]
260
+ },
261
+ "include": [
262
+ "jest.config.ts",
263
+ "src/**/*.test.ts",
264
+ "src/**/*.spec.ts",
265
+ "src/**/*.test.tsx",
266
+ "src/**/*.spec.tsx",
267
+ "src/**/*.test.js",
268
+ "src/**/*.spec.js",
269
+ "src/**/*.test.jsx",
270
+ "src/**/*.spec.jsx",
271
+ "src/**/*.d.ts"
272
+ ]
273
+ }
274
+ "
275
+ `);
276
+ expect(appTree.read('libs/my-lib/jest.config.ts', 'utf-8'))
277
+ .toMatchInlineSnapshot(`
278
+ "module.exports = {
279
+ displayName: 'my-lib',
280
+ preset: 'react-native',
281
+ resolver: '@nx/jest/plugins/resolver',
282
+ moduleFileExtensions: ['ts', 'js', 'html', 'tsx', 'jsx'],
283
+ setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
284
+ moduleNameMapper: {
285
+ '\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock',
286
+ },
287
+ coverageDirectory: '../../coverage/libs/my-lib',
288
+ };
289
+ "
290
+ `);
291
+ const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
292
+ expect(projectConfiguration.targets.test).toMatchInlineSnapshot(`
293
+ {
294
+ "configurations": {
295
+ "ci": {
296
+ "ci": true,
297
+ "codeCoverage": true,
298
+ },
299
+ },
300
+ "executor": "@nx/jest:jest",
301
+ "options": {
302
+ "jestConfig": "libs/my-lib/jest.config.ts",
303
+ "passWithNoTests": true,
304
+ },
305
+ "outputs": [
306
+ "{workspaceRoot}/coverage/{projectRoot}",
307
+ ],
308
+ }
309
+ `);
310
+ });
245
311
  });
246
312
 
247
313
  describe('--buildable', () => {
@@ -53,7 +53,7 @@ const customConfig = {
53
53
  resolver: {
54
54
  assetExts: assetExts.filter((ext) => ext !== 'svg'),
55
55
  sourceExts: [...sourceExts, 'svg'],
56
- blockList: exclusionList([/^(?!.*node_modules).*\/dist\/.*/]),
56
+ blockList: exclusionList([/^(?!.*node_modules).*\\/dist\\/.*/]),
57
57
  unstable_enableSymlinks: true,
58
58
  unstable_enablePackageExports: true,
59
59
  },
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addJest = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
5
6
  const jest_1 = require("@nx/jest");
6
7
  function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPackageJson) {
7
8
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -28,7 +29,8 @@ function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPack
28
29
  setupFilesAfterEnv: ['<rootDir>/test-setup.${js ? 'js' : 'ts'}'],
29
30
  moduleNameMapper: {
30
31
  '\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock'
31
- }
32
+ },
33
+ coverageDirectory: '${(0, devkit_1.offsetFromRoot)(appProjectRoot)}coverage/${appProjectRoot}'
32
34
  };`;
33
35
  host.write(configPath, content);
34
36
  return jestTask;