chore(react-native): update react-native plugin unit tests to use "as-provided" (#18945)
This commit is contained in:
parent
b17b30d13b
commit
fef332e537
@ -12,7 +12,7 @@ describe('app', () => {
|
|||||||
let appTree: Tree;
|
let appTree: Tree;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
appTree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
appTree = createTreeWithEmptyWorkspace();
|
||||||
appTree.write('.gitignore', '');
|
appTree.write('.gitignore', '');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -23,10 +23,11 @@ describe('app', () => {
|
|||||||
linter: Linter.EsLint,
|
linter: Linter.EsLint,
|
||||||
e2eTestRunner: 'none',
|
e2eTestRunner: 'none',
|
||||||
install: false,
|
install: false,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
const projects = getProjects(appTree);
|
const projects = getProjects(appTree);
|
||||||
|
|
||||||
expect(projects.get('my-app').root).toEqual('apps/my-app');
|
expect(projects.get('my-app').root).toEqual('my-app');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update nx.json', async () => {
|
it('should update nx.json', async () => {
|
||||||
@ -37,6 +38,7 @@ describe('app', () => {
|
|||||||
linter: Linter.EsLint,
|
linter: Linter.EsLint,
|
||||||
e2eTestRunner: 'none',
|
e2eTestRunner: 'none',
|
||||||
install: false,
|
install: false,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
|
|
||||||
const projectConfiguration = readProjectConfiguration(appTree, 'my-app');
|
const projectConfiguration = readProjectConfiguration(appTree, 'my-app');
|
||||||
@ -52,15 +54,16 @@ describe('app', () => {
|
|||||||
linter: Linter.EsLint,
|
linter: Linter.EsLint,
|
||||||
e2eTestRunner: 'none',
|
e2eTestRunner: 'none',
|
||||||
install: false,
|
install: false,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
expect(appTree.exists('apps/my-app/src/app/App.tsx')).toBeTruthy();
|
expect(appTree.exists('my-app/src/app/App.tsx')).toBeTruthy();
|
||||||
expect(appTree.exists('apps/my-app/src/main.tsx')).toBeTruthy();
|
expect(appTree.exists('my-app/src/main.tsx')).toBeTruthy();
|
||||||
|
|
||||||
const tsconfig = readJson(appTree, 'apps/my-app/tsconfig.json');
|
const tsconfig = readJson(appTree, 'my-app/tsconfig.json');
|
||||||
expect(tsconfig.extends).toEqual('../../tsconfig.base.json');
|
expect(tsconfig.extends).toEqual('../tsconfig.base.json');
|
||||||
|
|
||||||
expect(appTree.exists('apps/my-app/.eslintrc.json')).toBe(true);
|
expect(appTree.exists('my-app/.eslintrc.json')).toBe(true);
|
||||||
expect(appTree.read('apps/my-app/jest.config.ts', 'utf-8'))
|
expect(appTree.read('my-app/jest.config.ts', 'utf-8'))
|
||||||
.toMatchInlineSnapshot(`
|
.toMatchInlineSnapshot(`
|
||||||
"module.exports = {
|
"module.exports = {
|
||||||
displayName: 'my-app',
|
displayName: 'my-app',
|
||||||
@ -71,7 +74,7 @@ describe('app', () => {
|
|||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
'\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock',
|
'\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock',
|
||||||
},
|
},
|
||||||
coverageDirectory: '../../coverage/apps/my-app',
|
coverageDirectory: '../coverage/my-app',
|
||||||
};
|
};
|
||||||
"
|
"
|
||||||
`);
|
`);
|
||||||
@ -84,6 +87,7 @@ describe('app', () => {
|
|||||||
linter: Linter.EsLint,
|
linter: Linter.EsLint,
|
||||||
e2eTestRunner: 'none',
|
e2eTestRunner: 'none',
|
||||||
install: false,
|
install: false,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
const targets = readProjectConfiguration(appTree, 'my-app').targets;
|
const targets = readProjectConfiguration(appTree, 'my-app').targets;
|
||||||
expect(targets.test).toBeDefined();
|
expect(targets.test).toBeDefined();
|
||||||
@ -98,10 +102,11 @@ describe('app', () => {
|
|||||||
linter: Linter.EsLint,
|
linter: Linter.EsLint,
|
||||||
e2eTestRunner: 'none',
|
e2eTestRunner: 'none',
|
||||||
install: false,
|
install: false,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
|
|
||||||
const tsconfig = readJson(appTree, 'apps/my-app/tsconfig.json');
|
const tsconfig = readJson(appTree, 'my-app/tsconfig.json');
|
||||||
expect(tsconfig.extends).toEqual('../../tsconfig.json');
|
expect(tsconfig.extends).toEqual('../tsconfig.json');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('detox', () => {
|
describe('detox', () => {
|
||||||
@ -112,18 +117,14 @@ describe('app', () => {
|
|||||||
linter: Linter.EsLint,
|
linter: Linter.EsLint,
|
||||||
e2eTestRunner: 'detox',
|
e2eTestRunner: 'detox',
|
||||||
install: false,
|
install: false,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
|
|
||||||
const projects = getProjects(appTree);
|
const projects = getProjects(appTree);
|
||||||
expect(projects.get('my-dir-my-app').root).toEqual('apps/my-dir/my-app');
|
expect(projects.get('my-app').root).toEqual('my-dir');
|
||||||
|
|
||||||
expect(
|
expect(appTree.exists('my-dir-e2e/.detoxrc.json')).toBeTruthy();
|
||||||
appTree.exists('apps/my-dir/my-app-e2e/.detoxrc.json')
|
const detoxrc = appTree.read('my-dir-e2e/.detoxrc.json', 'utf-8');
|
||||||
).toBeTruthy();
|
|
||||||
const detoxrc = appTree.read(
|
|
||||||
'apps/my-dir/my-app-e2e/.detoxrc.json',
|
|
||||||
'utf-8'
|
|
||||||
);
|
|
||||||
// Strip trailing commas
|
// Strip trailing commas
|
||||||
const detoxrcJson = JSON.parse(
|
const detoxrcJson = JSON.parse(
|
||||||
detoxrc.replace(/(?<=(true|false|null|["\d}\]])\s*),(?=\s*[}\]])/g, '')
|
detoxrc.replace(/(?<=(true|false|null|["\d}\]])\s*),(?=\s*[}\]])/g, '')
|
||||||
@ -131,30 +132,30 @@ describe('app', () => {
|
|||||||
expect(detoxrcJson.apps).toEqual({
|
expect(detoxrcJson.apps).toEqual({
|
||||||
'android.debug': {
|
'android.debug': {
|
||||||
binaryPath:
|
binaryPath:
|
||||||
'../../../apps/my-dir/my-app/android/app/build/outputs/apk/debug/app-debug.apk',
|
'../my-dir/android/app/build/outputs/apk/debug/app-debug.apk',
|
||||||
build:
|
build:
|
||||||
'cd ../../../apps/my-dir/my-app/android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
|
'cd ../my-dir/android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
|
||||||
type: 'android.apk',
|
type: 'android.apk',
|
||||||
},
|
},
|
||||||
'android.release': {
|
'android.release': {
|
||||||
binaryPath:
|
binaryPath:
|
||||||
'../../../apps/my-dir/my-app/android/app/build/outputs/apk/release/app-release.apk',
|
'../my-dir/android/app/build/outputs/apk/release/app-release.apk',
|
||||||
build:
|
build:
|
||||||
'cd ../../../apps/my-dir/my-app/android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release',
|
'cd ../my-dir/android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release',
|
||||||
type: 'android.apk',
|
type: 'android.apk',
|
||||||
},
|
},
|
||||||
'ios.debug': {
|
'ios.debug': {
|
||||||
binaryPath:
|
binaryPath:
|
||||||
'../../../apps/my-dir/my-app/ios/build/Build/Products/Debug-iphonesimulator/MyApp.app',
|
'../my-dir/ios/build/Build/Products/Debug-iphonesimulator/MyApp.app',
|
||||||
build:
|
build:
|
||||||
"cd ../../../apps/my-dir/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
|
"cd ../my-dir/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
|
||||||
type: 'ios.app',
|
type: 'ios.app',
|
||||||
},
|
},
|
||||||
'ios.release': {
|
'ios.release': {
|
||||||
binaryPath:
|
binaryPath:
|
||||||
'../../../apps/my-dir/my-app/ios/build/Build/Products/Release-iphonesimulator/MyApp.app',
|
'../my-dir/ios/build/Build/Products/Release-iphonesimulator/MyApp.app',
|
||||||
build:
|
build:
|
||||||
"cd ../../../apps/my-dir/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
|
"cd ../my-dir/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
|
||||||
type: 'ios.app',
|
type: 'ios.app',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -166,12 +167,13 @@ describe('app', () => {
|
|||||||
linter: Linter.EsLint,
|
linter: Linter.EsLint,
|
||||||
e2eTestRunner: 'detox',
|
e2eTestRunner: 'detox',
|
||||||
install: false,
|
install: false,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
|
|
||||||
const projects = getProjects(appTree);
|
const projects = getProjects(appTree);
|
||||||
expect(projects.get('my-app').root).toEqual('apps/my-app');
|
expect(projects.get('my-app').root).toEqual('my-app');
|
||||||
|
|
||||||
const detoxrc = appTree.read('apps/my-app-e2e/.detoxrc.json', 'utf-8');
|
const detoxrc = appTree.read('my-app-e2e/.detoxrc.json', 'utf-8');
|
||||||
// Strip trailing commas
|
// Strip trailing commas
|
||||||
const detoxrcJson = JSON.parse(
|
const detoxrcJson = JSON.parse(
|
||||||
detoxrc.replace(/(?<=(true|false|null|["\d}\]])\s*),(?=\s*[}\]])/g, '')
|
detoxrc.replace(/(?<=(true|false|null|["\d}\]])\s*),(?=\s*[}\]])/g, '')
|
||||||
@ -179,30 +181,30 @@ describe('app', () => {
|
|||||||
expect(detoxrcJson.apps).toEqual({
|
expect(detoxrcJson.apps).toEqual({
|
||||||
'android.debug': {
|
'android.debug': {
|
||||||
binaryPath:
|
binaryPath:
|
||||||
'../../apps/my-app/android/app/build/outputs/apk/debug/app-debug.apk',
|
'../my-app/android/app/build/outputs/apk/debug/app-debug.apk',
|
||||||
build:
|
build:
|
||||||
'cd ../../apps/my-app/android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
|
'cd ../my-app/android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
|
||||||
type: 'android.apk',
|
type: 'android.apk',
|
||||||
},
|
},
|
||||||
'android.release': {
|
'android.release': {
|
||||||
binaryPath:
|
binaryPath:
|
||||||
'../../apps/my-app/android/app/build/outputs/apk/release/app-release.apk',
|
'../my-app/android/app/build/outputs/apk/release/app-release.apk',
|
||||||
build:
|
build:
|
||||||
'cd ../../apps/my-app/android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release',
|
'cd ../my-app/android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release',
|
||||||
type: 'android.apk',
|
type: 'android.apk',
|
||||||
},
|
},
|
||||||
'ios.debug': {
|
'ios.debug': {
|
||||||
binaryPath:
|
binaryPath:
|
||||||
'../../apps/my-app/ios/build/Build/Products/Debug-iphonesimulator/MyApp.app',
|
'../my-app/ios/build/Build/Products/Debug-iphonesimulator/MyApp.app',
|
||||||
build:
|
build:
|
||||||
"cd ../../apps/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
|
"cd ../my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
|
||||||
type: 'ios.app',
|
type: 'ios.app',
|
||||||
},
|
},
|
||||||
'ios.release': {
|
'ios.release': {
|
||||||
binaryPath:
|
binaryPath:
|
||||||
'../../apps/my-app/ios/build/Build/Products/Release-iphonesimulator/MyApp.app',
|
'../my-app/ios/build/Build/Products/Release-iphonesimulator/MyApp.app',
|
||||||
build:
|
build:
|
||||||
"cd ../../apps/my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
|
"cd ../my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
|
||||||
type: 'ios.app',
|
type: 'ios.app',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -220,6 +222,7 @@ describe('app', () => {
|
|||||||
e2eTestRunner: 'none',
|
e2eTestRunner: 'none',
|
||||||
install: false,
|
install: false,
|
||||||
skipPackageJson: true,
|
skipPackageJson: true,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(readJson(appTree, 'package.json')).toEqual(packageJsonBefore);
|
expect(readJson(appTree, 'package.json')).toEqual(packageJsonBefore);
|
||||||
|
|||||||
@ -8,7 +8,7 @@ describe('Normalize Options', () => {
|
|||||||
let appTree: Tree;
|
let appTree: Tree;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
appTree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
appTree = createTreeWithEmptyWorkspace();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should normalize options with name in kebab case', async () => {
|
it('should normalize options with name in kebab case', async () => {
|
||||||
@ -17,19 +17,20 @@ describe('Normalize Options', () => {
|
|||||||
linter: Linter.EsLint,
|
linter: Linter.EsLint,
|
||||||
e2eTestRunner: 'none',
|
e2eTestRunner: 'none',
|
||||||
install: false,
|
install: false,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
};
|
};
|
||||||
const options = await normalizeOptions(appTree, schema);
|
const options = await normalizeOptions(appTree, schema);
|
||||||
expect(options).toEqual({
|
expect(options).toEqual({
|
||||||
androidProjectRoot: 'apps/my-app/android',
|
androidProjectRoot: 'my-app/android',
|
||||||
appProjectRoot: 'apps/my-app',
|
appProjectRoot: 'my-app',
|
||||||
className: 'MyApp',
|
className: 'MyApp',
|
||||||
displayName: 'MyApp',
|
displayName: 'MyApp',
|
||||||
iosProjectRoot: 'apps/my-app/ios',
|
iosProjectRoot: 'my-app/ios',
|
||||||
lowerCaseName: 'myapp',
|
lowerCaseName: 'myapp',
|
||||||
name: 'my-app',
|
name: 'my-app',
|
||||||
parsedTags: [],
|
parsedTags: [],
|
||||||
projectName: 'my-app',
|
projectName: 'my-app',
|
||||||
projectNameAndRootFormat: 'derived',
|
projectNameAndRootFormat: 'as-provided',
|
||||||
linter: Linter.EsLint,
|
linter: Linter.EsLint,
|
||||||
entryFile: 'src/main.tsx',
|
entryFile: 'src/main.tsx',
|
||||||
e2eTestRunner: 'none',
|
e2eTestRunner: 'none',
|
||||||
@ -43,19 +44,20 @@ describe('Normalize Options', () => {
|
|||||||
name: 'myApp',
|
name: 'myApp',
|
||||||
e2eTestRunner: 'none',
|
e2eTestRunner: 'none',
|
||||||
install: false,
|
install: false,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
};
|
};
|
||||||
const options = await normalizeOptions(appTree, schema);
|
const options = await normalizeOptions(appTree, schema);
|
||||||
expect(options).toEqual({
|
expect(options).toEqual({
|
||||||
androidProjectRoot: 'apps/my-app/android',
|
androidProjectRoot: 'my-app/android',
|
||||||
appProjectRoot: 'apps/my-app',
|
appProjectRoot: 'my-app',
|
||||||
className: 'MyApp',
|
className: 'MyApp',
|
||||||
displayName: 'MyApp',
|
displayName: 'MyApp',
|
||||||
iosProjectRoot: 'apps/my-app/ios',
|
iosProjectRoot: 'my-app/ios',
|
||||||
lowerCaseName: 'myapp',
|
lowerCaseName: 'myapp',
|
||||||
name: 'my-app',
|
name: 'my-app',
|
||||||
parsedTags: [],
|
parsedTags: [],
|
||||||
projectName: 'my-app',
|
projectName: 'my-app',
|
||||||
projectNameAndRootFormat: 'derived',
|
projectNameAndRootFormat: 'as-provided',
|
||||||
entryFile: 'src/main.tsx',
|
entryFile: 'src/main.tsx',
|
||||||
e2eTestRunner: 'none',
|
e2eTestRunner: 'none',
|
||||||
unitTestRunner: 'jest',
|
unitTestRunner: 'jest',
|
||||||
@ -66,23 +68,24 @@ describe('Normalize Options', () => {
|
|||||||
it('should normalize options with directory', async () => {
|
it('should normalize options with directory', async () => {
|
||||||
const schema: Schema = {
|
const schema: Schema = {
|
||||||
name: 'my-app',
|
name: 'my-app',
|
||||||
directory: 'directory',
|
directory: 'directory/my-app',
|
||||||
e2eTestRunner: 'none',
|
e2eTestRunner: 'none',
|
||||||
install: false,
|
install: false,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
};
|
};
|
||||||
const options = await normalizeOptions(appTree, schema);
|
const options = await normalizeOptions(appTree, schema);
|
||||||
expect(options).toEqual({
|
expect(options).toEqual({
|
||||||
androidProjectRoot: 'apps/directory/my-app/android',
|
androidProjectRoot: 'directory/my-app/android',
|
||||||
appProjectRoot: 'apps/directory/my-app',
|
appProjectRoot: 'directory/my-app',
|
||||||
className: 'MyApp',
|
className: 'MyApp',
|
||||||
displayName: 'MyApp',
|
displayName: 'MyApp',
|
||||||
iosProjectRoot: 'apps/directory/my-app/ios',
|
iosProjectRoot: 'directory/my-app/ios',
|
||||||
lowerCaseName: 'myapp',
|
lowerCaseName: 'myapp',
|
||||||
name: 'my-app',
|
name: 'my-app',
|
||||||
directory: 'directory',
|
directory: 'directory/my-app',
|
||||||
parsedTags: [],
|
parsedTags: [],
|
||||||
projectName: 'directory-my-app',
|
projectName: 'my-app',
|
||||||
projectNameAndRootFormat: 'derived',
|
projectNameAndRootFormat: 'as-provided',
|
||||||
entryFile: 'src/main.tsx',
|
entryFile: 'src/main.tsx',
|
||||||
e2eTestRunner: 'none',
|
e2eTestRunner: 'none',
|
||||||
unitTestRunner: 'jest',
|
unitTestRunner: 'jest',
|
||||||
@ -95,19 +98,20 @@ describe('Normalize Options', () => {
|
|||||||
name: 'directory/my-app',
|
name: 'directory/my-app',
|
||||||
e2eTestRunner: 'none',
|
e2eTestRunner: 'none',
|
||||||
install: false,
|
install: false,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
};
|
};
|
||||||
const options = await normalizeOptions(appTree, schema);
|
const options = await normalizeOptions(appTree, schema);
|
||||||
expect(options).toEqual({
|
expect(options).toEqual({
|
||||||
androidProjectRoot: 'apps/directory/my-app/android',
|
androidProjectRoot: 'directory/my-app/android',
|
||||||
appProjectRoot: 'apps/directory/my-app',
|
appProjectRoot: 'directory/my-app',
|
||||||
className: 'DirectoryMyApp',
|
className: 'DirectoryMyApp',
|
||||||
displayName: 'DirectoryMyApp',
|
displayName: 'DirectoryMyApp',
|
||||||
iosProjectRoot: 'apps/directory/my-app/ios',
|
iosProjectRoot: 'directory/my-app/ios',
|
||||||
lowerCaseName: 'directorymyapp',
|
lowerCaseName: 'directorymyapp',
|
||||||
name: 'directory/my-app',
|
name: 'directory/my-app',
|
||||||
parsedTags: [],
|
parsedTags: [],
|
||||||
projectName: 'directory-my-app',
|
projectName: 'directory/my-app',
|
||||||
projectNameAndRootFormat: 'derived',
|
projectNameAndRootFormat: 'as-provided',
|
||||||
entryFile: 'src/main.tsx',
|
entryFile: 'src/main.tsx',
|
||||||
e2eTestRunner: 'none',
|
e2eTestRunner: 'none',
|
||||||
unitTestRunner: 'jest',
|
unitTestRunner: 'jest',
|
||||||
@ -121,19 +125,20 @@ describe('Normalize Options', () => {
|
|||||||
displayName: 'My App',
|
displayName: 'My App',
|
||||||
e2eTestRunner: 'none',
|
e2eTestRunner: 'none',
|
||||||
install: false,
|
install: false,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
};
|
};
|
||||||
const options = await normalizeOptions(appTree, schema);
|
const options = await normalizeOptions(appTree, schema);
|
||||||
expect(options).toEqual({
|
expect(options).toEqual({
|
||||||
androidProjectRoot: 'apps/my-app/android',
|
androidProjectRoot: 'my-app/android',
|
||||||
appProjectRoot: 'apps/my-app',
|
appProjectRoot: 'my-app',
|
||||||
className: 'MyApp',
|
className: 'MyApp',
|
||||||
displayName: 'My App',
|
displayName: 'My App',
|
||||||
iosProjectRoot: 'apps/my-app/ios',
|
iosProjectRoot: 'my-app/ios',
|
||||||
lowerCaseName: 'myapp',
|
lowerCaseName: 'myapp',
|
||||||
name: 'my-app',
|
name: 'my-app',
|
||||||
parsedTags: [],
|
parsedTags: [],
|
||||||
projectName: 'my-app',
|
projectName: 'my-app',
|
||||||
projectNameAndRootFormat: 'derived',
|
projectNameAndRootFormat: 'as-provided',
|
||||||
entryFile: 'src/main.tsx',
|
entryFile: 'src/main.tsx',
|
||||||
e2eTestRunner: 'none',
|
e2eTestRunner: 'none',
|
||||||
unitTestRunner: 'jest',
|
unitTestRunner: 'jest',
|
||||||
|
|||||||
@ -9,9 +9,8 @@ import componentGenerator from '../component/component';
|
|||||||
|
|
||||||
describe('react-native:component-story', () => {
|
describe('react-native:component-story', () => {
|
||||||
let appTree: Tree;
|
let appTree: Tree;
|
||||||
let cmpPath = 'libs/test-ui-lib/src/lib/test-ui-lib/test-ui-lib.tsx';
|
let cmpPath = 'test-ui-lib/src/lib/test-ui-lib/test-ui-lib.tsx';
|
||||||
let storyFilePath =
|
let storyFilePath = 'test-ui-lib/src/lib/test-ui-lib/test-ui-lib.stories.tsx';
|
||||||
'libs/test-ui-lib/src/lib/test-ui-lib/test-ui-lib.stories.tsx';
|
|
||||||
|
|
||||||
describe('default setup', () => {
|
describe('default setup', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
@ -34,7 +33,7 @@ describe('react-native:component-story', () => {
|
|||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
expect(e.message).toContain(
|
expect(e.message).toContain(
|
||||||
'Could not find any React Native component in file libs/test-ui-lib/src/lib/test-ui-lib/test-ui-lib.tsx'
|
'Could not find any React Native component in file test-ui-lib/src/lib/test-ui-lib/test-ui-lib.tsx'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -70,11 +69,11 @@ describe('react-native:component-story', () => {
|
|||||||
|
|
||||||
describe('when using plain JS components', () => {
|
describe('when using plain JS components', () => {
|
||||||
let storyFilePathPlain =
|
let storyFilePathPlain =
|
||||||
'libs/test-ui-lib/src/lib/test-ui-libplain.stories.jsx';
|
'test-ui-lib/src/lib/test-ui-libplain.stories.jsx';
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
appTree.write(
|
appTree.write(
|
||||||
'libs/test-ui-lib/src/lib/test-ui-libplain.jsx',
|
'test-ui-lib/src/lib/test-ui-libplain.jsx',
|
||||||
`import React from 'react';
|
`import React from 'react';
|
||||||
|
|
||||||
import './test.scss';
|
import './test.scss';
|
||||||
@ -400,7 +399,7 @@ describe('react-native:component-story', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export async function createTestUILib(libName: string): Promise<Tree> {
|
export async function createTestUILib(libName: string): Promise<Tree> {
|
||||||
let appTree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
let appTree = createTreeWithEmptyWorkspace();
|
||||||
appTree.write('.gitignore', '');
|
appTree.write('.gitignore', '');
|
||||||
|
|
||||||
await libraryGenerator(appTree, {
|
await libraryGenerator(appTree, {
|
||||||
@ -409,6 +408,7 @@ export async function createTestUILib(libName: string): Promise<Tree> {
|
|||||||
skipFormat: true,
|
skipFormat: true,
|
||||||
skipTsConfig: false,
|
skipTsConfig: false,
|
||||||
unitTestRunner: 'jest',
|
unitTestRunner: 'jest',
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
|
|
||||||
await componentGenerator(appTree, {
|
await componentGenerator(appTree, {
|
||||||
|
|||||||
@ -9,7 +9,7 @@ describe('component', () => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
projectName = 'my-lib';
|
projectName = 'my-lib';
|
||||||
appTree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
appTree = createTreeWithEmptyWorkspace();
|
||||||
appTree.write('.gitignore', '');
|
appTree.write('.gitignore', '');
|
||||||
await createApp(appTree, 'my-app');
|
await createApp(appTree, 'my-app');
|
||||||
await createLib(appTree, projectName);
|
await createLib(appTree, projectName);
|
||||||
@ -21,16 +21,14 @@ describe('component', () => {
|
|||||||
jest.restoreAllMocks();
|
jest.restoreAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should generate files', async () => {
|
it('should generate component files', async () => {
|
||||||
await reactNativeComponentGenerator(appTree, {
|
await reactNativeComponentGenerator(appTree, {
|
||||||
name: 'hello',
|
name: 'hello',
|
||||||
project: projectName,
|
project: projectName,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(appTree.exists('libs/my-lib/src/lib/hello/hello.tsx')).toBeTruthy();
|
expect(appTree.exists('my-lib/src/lib/hello/hello.tsx')).toBeTruthy();
|
||||||
expect(
|
expect(appTree.exists('my-lib/src/lib/hello/hello.spec.tsx')).toBeTruthy();
|
||||||
appTree.exists('libs/my-lib/src/lib/hello/hello.spec.tsx')
|
|
||||||
).toBeTruthy();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should generate files for an app', async () => {
|
it('should generate files for an app', async () => {
|
||||||
@ -39,10 +37,8 @@ describe('component', () => {
|
|||||||
project: 'my-app',
|
project: 'my-app',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(appTree.exists('apps/my-app/src/app/hello/hello.tsx')).toBeTruthy();
|
expect(appTree.exists('my-app/src/app/hello/hello.tsx')).toBeTruthy();
|
||||||
expect(
|
expect(appTree.exists('my-app/src/app/hello/hello.spec.tsx')).toBeTruthy();
|
||||||
appTree.exists('apps/my-app/src/app/hello/hello.spec.tsx')
|
|
||||||
).toBeTruthy();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('--export', () => {
|
describe('--export', () => {
|
||||||
@ -53,7 +49,7 @@ describe('component', () => {
|
|||||||
export: true,
|
export: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const indexContent = appTree.read('libs/my-lib/src/index.ts', 'utf-8');
|
const indexContent = appTree.read('my-lib/src/index.ts', 'utf-8');
|
||||||
|
|
||||||
expect(indexContent).toMatch(/lib\/hello/);
|
expect(indexContent).toMatch(/lib\/hello/);
|
||||||
});
|
});
|
||||||
@ -65,7 +61,7 @@ describe('component', () => {
|
|||||||
export: true,
|
export: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const indexContent = appTree.read('libs/my-lib/src/index.ts', 'utf-8');
|
const indexContent = appTree.read('my-lib/src/index.ts', 'utf-8');
|
||||||
|
|
||||||
expect(indexContent).not.toMatch(/lib\/hello/);
|
expect(indexContent).not.toMatch(/lib\/hello/);
|
||||||
});
|
});
|
||||||
@ -78,11 +74,9 @@ describe('component', () => {
|
|||||||
project: projectName,
|
project: projectName,
|
||||||
pascalCaseFiles: true,
|
pascalCaseFiles: true,
|
||||||
});
|
});
|
||||||
|
expect(appTree.exists('my-lib/src/lib/hello/Hello.tsx')).toBeTruthy();
|
||||||
expect(
|
expect(
|
||||||
appTree.exists('libs/my-lib/src/lib/hello/Hello.tsx')
|
appTree.exists('my-lib/src/lib/hello/Hello.spec.tsx')
|
||||||
).toBeTruthy();
|
|
||||||
expect(
|
|
||||||
appTree.exists('libs/my-lib/src/lib/hello/Hello.spec.tsx')
|
|
||||||
).toBeTruthy();
|
).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -95,7 +89,7 @@ describe('component', () => {
|
|||||||
directory: 'components',
|
directory: 'components',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(appTree.exists('/libs/my-lib/src/components/hello/hello.tsx'));
|
expect(appTree.exists('my-lib/src/components/hello/hello.tsx'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create with nested directories', async () => {
|
it('should create with nested directories', async () => {
|
||||||
@ -105,9 +99,7 @@ describe('component', () => {
|
|||||||
directory: 'lib/foo',
|
directory: 'lib/foo',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(
|
expect(appTree.exists('my-lib/src/lib/foo/hello-world/hello-world.tsx'));
|
||||||
appTree.exists('/libs/my-lib/src/lib/foo/hello-world/hello-world.tsx')
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -119,7 +111,7 @@ describe('component', () => {
|
|||||||
flat: true,
|
flat: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(appTree.exists('/libs/my-lib/src/lib/hello.tsx'));
|
expect(appTree.exists('my-lib/src/lib/hello.tsx'));
|
||||||
});
|
});
|
||||||
it('should work with custom directory path', async () => {
|
it('should work with custom directory path', async () => {
|
||||||
await reactNativeComponentGenerator(appTree, {
|
await reactNativeComponentGenerator(appTree, {
|
||||||
@ -129,7 +121,7 @@ describe('component', () => {
|
|||||||
directory: 'components',
|
directory: 'components',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(appTree.exists('/libs/my-lib/src/components/hello.tsx'));
|
expect(appTree.exists('my-lib/src/components/hello.tsx'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -7,7 +7,7 @@ describe('init', () => {
|
|||||||
let tree: Tree;
|
let tree: Tree;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
tree = createTreeWithEmptyWorkspace();
|
||||||
tree.write('.gitignore', '');
|
tree.write('.gitignore', '');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -19,10 +19,11 @@ describe('lib', () => {
|
|||||||
skipTsConfig: false,
|
skipTsConfig: false,
|
||||||
unitTestRunner: 'jest',
|
unitTestRunner: 'jest',
|
||||||
strict: true,
|
strict: true,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
appTree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
appTree = createTreeWithEmptyWorkspace();
|
||||||
appTree.write('.gitignore', '');
|
appTree.write('.gitignore', '');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -30,13 +31,13 @@ describe('lib', () => {
|
|||||||
it('should update project.json', async () => {
|
it('should update project.json', async () => {
|
||||||
await libraryGenerator(appTree, { ...defaultSchema, tags: 'one,two' });
|
await libraryGenerator(appTree, { ...defaultSchema, tags: 'one,two' });
|
||||||
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
||||||
expect(projectConfiguration.root).toEqual('libs/my-lib');
|
expect(projectConfiguration.root).toEqual('my-lib');
|
||||||
expect(projectConfiguration.targets.build).toBeUndefined();
|
expect(projectConfiguration.targets.build).toBeUndefined();
|
||||||
expect(projectConfiguration.targets.lint).toEqual({
|
expect(projectConfiguration.targets.lint).toEqual({
|
||||||
executor: '@nx/linter:eslint',
|
executor: '@nx/linter:eslint',
|
||||||
outputs: ['{options.outputFile}'],
|
outputs: ['{options.outputFile}'],
|
||||||
options: {
|
options: {
|
||||||
lintFilePatterns: ['libs/my-lib/**/*.{ts,tsx,js,jsx}'],
|
lintFilePatterns: ['my-lib/**/*.{ts,tsx,js,jsx}'],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(projectConfiguration.tags).toEqual(['one', 'two']);
|
expect(projectConfiguration.tags).toEqual(['one', 'two']);
|
||||||
@ -46,7 +47,7 @@ describe('lib', () => {
|
|||||||
await libraryGenerator(appTree, defaultSchema);
|
await libraryGenerator(appTree, defaultSchema);
|
||||||
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
||||||
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
||||||
'libs/my-lib/src/index.ts',
|
'my-lib/src/index.ts',
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ describe('lib', () => {
|
|||||||
|
|
||||||
const tsconfigJson = readJson(appTree, '/tsconfig.json');
|
const tsconfigJson = readJson(appTree, '/tsconfig.json');
|
||||||
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
||||||
'libs/my-lib/src/index.ts',
|
'my-lib/src/index.ts',
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -70,15 +71,15 @@ describe('lib', () => {
|
|||||||
await libraryGenerator(appTree, defaultSchema);
|
await libraryGenerator(appTree, defaultSchema);
|
||||||
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
||||||
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
||||||
'libs/my-lib/src/index.ts',
|
'my-lib/src/index.ts',
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a local tsconfig.json', async () => {
|
it('should create a local tsconfig.json', async () => {
|
||||||
await libraryGenerator(appTree, defaultSchema);
|
await libraryGenerator(appTree, defaultSchema);
|
||||||
|
|
||||||
const tsconfigJson = readJson(appTree, 'libs/my-lib/tsconfig.json');
|
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.json');
|
||||||
expect(tsconfigJson.extends).toBe('../../tsconfig.base.json');
|
expect(tsconfigJson.extends).toBe('../tsconfig.base.json');
|
||||||
expect(tsconfigJson.references).toEqual([
|
expect(tsconfigJson.references).toEqual([
|
||||||
{
|
{
|
||||||
path: './tsconfig.lib.json',
|
path: './tsconfig.lib.json',
|
||||||
@ -102,19 +103,19 @@ describe('lib', () => {
|
|||||||
|
|
||||||
await libraryGenerator(appTree, defaultSchema);
|
await libraryGenerator(appTree, defaultSchema);
|
||||||
|
|
||||||
const tsconfigJson = readJson(appTree, 'libs/my-lib/tsconfig.json');
|
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.json');
|
||||||
expect(tsconfigJson.extends).toBe('../../tsconfig.json');
|
expect(tsconfigJson.extends).toBe('../tsconfig.json');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should extend the local tsconfig.json with tsconfig.spec.json', async () => {
|
it('should extend the local tsconfig.json with tsconfig.spec.json', async () => {
|
||||||
await libraryGenerator(appTree, defaultSchema);
|
await libraryGenerator(appTree, defaultSchema);
|
||||||
const tsconfigJson = readJson(appTree, 'libs/my-lib/tsconfig.spec.json');
|
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.spec.json');
|
||||||
expect(tsconfigJson.extends).toEqual('./tsconfig.json');
|
expect(tsconfigJson.extends).toEqual('./tsconfig.json');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should extend the local tsconfig.json with tsconfig.lib.json', async () => {
|
it('should extend the local tsconfig.json with tsconfig.lib.json', async () => {
|
||||||
await libraryGenerator(appTree, defaultSchema);
|
await libraryGenerator(appTree, defaultSchema);
|
||||||
const tsconfigJson = readJson(appTree, 'libs/my-lib/tsconfig.lib.json');
|
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.lib.json');
|
||||||
expect(tsconfigJson.extends).toEqual('./tsconfig.json');
|
expect(tsconfigJson.extends).toEqual('./tsconfig.json');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -126,10 +127,8 @@ describe('lib', () => {
|
|||||||
directory: 'myDir',
|
directory: 'myDir',
|
||||||
tags: 'one',
|
tags: 'one',
|
||||||
});
|
});
|
||||||
const projectConfiguration = readProjectConfiguration(
|
|
||||||
appTree,
|
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
||||||
'my-dir-my-lib'
|
|
||||||
);
|
|
||||||
expect(projectConfiguration).toMatchObject({
|
expect(projectConfiguration).toMatchObject({
|
||||||
tags: ['one'],
|
tags: ['one'],
|
||||||
});
|
});
|
||||||
@ -137,13 +136,13 @@ describe('lib', () => {
|
|||||||
await libraryGenerator(appTree, {
|
await libraryGenerator(appTree, {
|
||||||
...defaultSchema,
|
...defaultSchema,
|
||||||
name: 'myLib2',
|
name: 'myLib2',
|
||||||
directory: 'myDir',
|
directory: 'myDir2',
|
||||||
tags: 'one,two',
|
tags: 'one,two',
|
||||||
});
|
});
|
||||||
|
|
||||||
const lib2ProjectConfiguration = readProjectConfiguration(
|
const lib2ProjectConfiguration = readProjectConfiguration(
|
||||||
appTree,
|
appTree,
|
||||||
'my-dir-my-lib2'
|
'my-lib2'
|
||||||
);
|
);
|
||||||
expect(lib2ProjectConfiguration).toMatchObject({
|
expect(lib2ProjectConfiguration).toMatchObject({
|
||||||
tags: ['one', 'two'],
|
tags: ['one', 'two'],
|
||||||
@ -152,17 +151,14 @@ describe('lib', () => {
|
|||||||
|
|
||||||
it('should update project.json', async () => {
|
it('should update project.json', async () => {
|
||||||
await libraryGenerator(appTree, { ...defaultSchema, directory: 'myDir' });
|
await libraryGenerator(appTree, { ...defaultSchema, directory: 'myDir' });
|
||||||
const projectConfiguration = readProjectConfiguration(
|
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
||||||
appTree,
|
|
||||||
'my-dir-my-lib'
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(projectConfiguration.root).toEqual('libs/my-dir/my-lib');
|
expect(projectConfiguration.root).toEqual('my-dir');
|
||||||
expect(projectConfiguration.targets.lint).toEqual({
|
expect(projectConfiguration.targets.lint).toEqual({
|
||||||
executor: '@nx/linter:eslint',
|
executor: '@nx/linter:eslint',
|
||||||
outputs: ['{options.outputFile}'],
|
outputs: ['{options.outputFile}'],
|
||||||
options: {
|
options: {
|
||||||
lintFilePatterns: ['libs/my-dir/my-lib/**/*.{ts,tsx,js,jsx}'],
|
lintFilePatterns: ['my-dir/**/*.{ts,tsx,js,jsx}'],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -170,9 +166,9 @@ describe('lib', () => {
|
|||||||
it('should update root tsconfig.base.json', async () => {
|
it('should update root tsconfig.base.json', async () => {
|
||||||
await libraryGenerator(appTree, { ...defaultSchema, directory: 'myDir' });
|
await libraryGenerator(appTree, { ...defaultSchema, directory: 'myDir' });
|
||||||
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
||||||
expect(tsconfigJson.compilerOptions.paths['@proj/my-dir/my-lib']).toEqual(
|
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
||||||
['libs/my-dir/my-lib/src/index.ts']
|
'my-dir/src/index.ts',
|
||||||
);
|
]);
|
||||||
expect(
|
expect(
|
||||||
tsconfigJson.compilerOptions.paths['my-dir-my-lib/*']
|
tsconfigJson.compilerOptions.paths['my-dir-my-lib/*']
|
||||||
).toBeUndefined();
|
).toBeUndefined();
|
||||||
@ -184,9 +180,9 @@ describe('lib', () => {
|
|||||||
await libraryGenerator(appTree, { ...defaultSchema, directory: 'myDir' });
|
await libraryGenerator(appTree, { ...defaultSchema, directory: 'myDir' });
|
||||||
|
|
||||||
const tsconfigJson = readJson(appTree, '/tsconfig.json');
|
const tsconfigJson = readJson(appTree, '/tsconfig.json');
|
||||||
expect(tsconfigJson.compilerOptions.paths['@proj/my-dir/my-lib']).toEqual(
|
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
||||||
['libs/my-dir/my-lib/src/index.ts']
|
'my-dir/src/index.ts',
|
||||||
);
|
]);
|
||||||
expect(
|
expect(
|
||||||
tsconfigJson.compilerOptions.paths['my-dir-my-lib/*']
|
tsconfigJson.compilerOptions.paths['my-dir-my-lib/*']
|
||||||
).toBeUndefined();
|
).toBeUndefined();
|
||||||
@ -195,11 +191,8 @@ describe('lib', () => {
|
|||||||
it('should create a local tsconfig.json', async () => {
|
it('should create a local tsconfig.json', async () => {
|
||||||
await libraryGenerator(appTree, { ...defaultSchema, directory: 'myDir' });
|
await libraryGenerator(appTree, { ...defaultSchema, directory: 'myDir' });
|
||||||
|
|
||||||
const tsconfigJson = readJson(
|
const tsconfigJson = readJson(appTree, 'my-dir/tsconfig.json');
|
||||||
appTree,
|
expect(tsconfigJson.extends).toBe('../tsconfig.base.json');
|
||||||
'libs/my-dir/my-lib/tsconfig.json'
|
|
||||||
);
|
|
||||||
expect(tsconfigJson.extends).toBe('../../../tsconfig.base.json');
|
|
||||||
expect(tsconfigJson.references).toEqual([
|
expect(tsconfigJson.references).toEqual([
|
||||||
{
|
{
|
||||||
path: './tsconfig.lib.json',
|
path: './tsconfig.lib.json',
|
||||||
@ -215,11 +208,8 @@ describe('lib', () => {
|
|||||||
|
|
||||||
await libraryGenerator(appTree, { ...defaultSchema, directory: 'myDir' });
|
await libraryGenerator(appTree, { ...defaultSchema, directory: 'myDir' });
|
||||||
|
|
||||||
const tsconfigJson = readJson(
|
const tsconfigJson = readJson(appTree, 'my-dir/tsconfig.json');
|
||||||
appTree,
|
expect(tsconfigJson.extends).toBe('../tsconfig.json');
|
||||||
'libs/my-dir/my-lib/tsconfig.json'
|
|
||||||
);
|
|
||||||
expect(tsconfigJson.extends).toBe('../../../tsconfig.json');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -230,14 +220,14 @@ describe('lib', () => {
|
|||||||
unitTestRunner: 'none',
|
unitTestRunner: 'none',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(appTree.exists('libs/my-lib/tsconfig.spec.json')).toBeFalsy();
|
expect(appTree.exists('my-lib/tsconfig.spec.json')).toBeFalsy();
|
||||||
expect(appTree.exists('libs/my-lib/jest.config.ts')).toBeFalsy();
|
expect(appTree.exists('my-lib/jest.config.ts')).toBeFalsy();
|
||||||
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
||||||
expect(projectConfiguration.targets.test).toBeUndefined();
|
expect(projectConfiguration.targets.test).toBeUndefined();
|
||||||
expect(projectConfiguration.targets.lint).toMatchObject({
|
expect(projectConfiguration.targets.lint).toMatchObject({
|
||||||
executor: '@nx/linter:eslint',
|
executor: '@nx/linter:eslint',
|
||||||
options: {
|
options: {
|
||||||
lintFilePatterns: ['libs/my-lib/**/*.{ts,tsx,js,jsx}'],
|
lintFilePatterns: ['my-lib/**/*.{ts,tsx,js,jsx}'],
|
||||||
},
|
},
|
||||||
outputs: ['{options.outputFile}'],
|
outputs: ['{options.outputFile}'],
|
||||||
});
|
});
|
||||||
@ -249,12 +239,12 @@ describe('lib', () => {
|
|||||||
unitTestRunner: 'jest',
|
unitTestRunner: 'jest',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(appTree.read('libs/my-lib/tsconfig.spec.json', 'utf-8'))
|
expect(appTree.read('my-lib/tsconfig.spec.json', 'utf-8'))
|
||||||
.toMatchInlineSnapshot(`
|
.toMatchInlineSnapshot(`
|
||||||
"{
|
"{
|
||||||
"extends": "./tsconfig.json",
|
"extends": "./tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "../../dist/out-tsc",
|
"outDir": "../dist/out-tsc",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"types": ["jest", "node"]
|
"types": ["jest", "node"]
|
||||||
},
|
},
|
||||||
@ -273,7 +263,7 @@ describe('lib', () => {
|
|||||||
}
|
}
|
||||||
"
|
"
|
||||||
`);
|
`);
|
||||||
expect(appTree.read('libs/my-lib/jest.config.ts', 'utf-8'))
|
expect(appTree.read('my-lib/jest.config.ts', 'utf-8'))
|
||||||
.toMatchInlineSnapshot(`
|
.toMatchInlineSnapshot(`
|
||||||
"module.exports = {
|
"module.exports = {
|
||||||
displayName: 'my-lib',
|
displayName: 'my-lib',
|
||||||
@ -284,7 +274,7 @@ describe('lib', () => {
|
|||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
'\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock',
|
'\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock',
|
||||||
},
|
},
|
||||||
coverageDirectory: '../../coverage/libs/my-lib',
|
coverageDirectory: '../coverage/my-lib',
|
||||||
};
|
};
|
||||||
"
|
"
|
||||||
`);
|
`);
|
||||||
@ -299,7 +289,7 @@ describe('lib', () => {
|
|||||||
},
|
},
|
||||||
"executor": "@nx/jest:jest",
|
"executor": "@nx/jest:jest",
|
||||||
"options": {
|
"options": {
|
||||||
"jestConfig": "libs/my-lib/jest.config.ts",
|
"jestConfig": "my-lib/jest.config.ts",
|
||||||
"passWithNoTests": true,
|
"passWithNoTests": true,
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@ -338,10 +328,10 @@ describe('lib', () => {
|
|||||||
outputs: ['{options.outputPath}'],
|
outputs: ['{options.outputPath}'],
|
||||||
options: {
|
options: {
|
||||||
external: ['react/jsx-runtime', 'react-native', 'react', 'react-dom'],
|
external: ['react/jsx-runtime', 'react-native', 'react', 'react-dom'],
|
||||||
entryFile: 'libs/my-lib/src/index.ts',
|
entryFile: 'my-lib/src/index.ts',
|
||||||
outputPath: 'dist/libs/my-lib',
|
outputPath: 'dist/my-lib',
|
||||||
project: 'libs/my-lib/package.json',
|
project: 'my-lib/package.json',
|
||||||
tsConfig: 'libs/my-lib/tsconfig.lib.json',
|
tsConfig: 'my-lib/tsconfig.lib.json',
|
||||||
rollupConfig: '@nx/react/plugins/bundle-rollup',
|
rollupConfig: '@nx/react/plugins/bundle-rollup',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -370,9 +360,9 @@ describe('lib', () => {
|
|||||||
importPath: '@proj/my-lib',
|
importPath: '@proj/my-lib',
|
||||||
});
|
});
|
||||||
|
|
||||||
const packageJson = readJson(appTree, '/libs/my-lib/package.json');
|
const packageJson = readJson(appTree, 'my-lib/package.json');
|
||||||
expect(packageJson.name).toEqual('@proj/my-lib');
|
expect(packageJson.name).toEqual('@proj/my-lib');
|
||||||
expect(appTree.exists('/libs/my-lib/.babelrc'));
|
expect(appTree.exists('my-lib/.babelrc'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -383,7 +373,7 @@ describe('lib', () => {
|
|||||||
js: true,
|
js: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(appTree.exists('/libs/my-lib/src/index.js')).toBe(true);
|
expect(appTree.exists('my-lib/src/index.js')).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -395,7 +385,7 @@ describe('lib', () => {
|
|||||||
directory: 'myDir',
|
directory: 'myDir',
|
||||||
importPath: '@myorg/lib',
|
importPath: '@myorg/lib',
|
||||||
});
|
});
|
||||||
const packageJson = readJson(appTree, 'libs/my-dir/my-lib/package.json');
|
const packageJson = readJson(appTree, 'my-dir/package.json');
|
||||||
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
||||||
|
|
||||||
expect(packageJson.name).toBe('@myorg/lib');
|
expect(packageJson.name).toBe('@myorg/lib');
|
||||||
@ -435,7 +425,7 @@ describe('lib', () => {
|
|||||||
...defaultSchema,
|
...defaultSchema,
|
||||||
strict: false,
|
strict: false,
|
||||||
});
|
});
|
||||||
const tsconfigJson = readJson(appTree, '/libs/my-lib/tsconfig.json');
|
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.json');
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
tsconfigJson.compilerOptions.forceConsistentCasingInFileNames
|
tsconfigJson.compilerOptions.forceConsistentCasingInFileNames
|
||||||
|
|||||||
@ -21,14 +21,10 @@ describe('react:stories for applications', () => {
|
|||||||
project: 'test-ui-app',
|
project: 'test-ui-app',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(appTree.exists('apps/test-ui-app/src/app/App.tsx')).toBeTruthy();
|
expect(appTree.exists('test-ui-app/src/app/App.tsx')).toBeTruthy();
|
||||||
|
expect(appTree.exists('test-ui-app/src/app/App.stories.tsx')).toBeTruthy();
|
||||||
expect(
|
expect(
|
||||||
appTree.exists('apps/test-ui-app/src/app/App.stories.tsx')
|
appTree.exists('test-ui-app/src/app/another-cmp/another-cmp.stories.tsx')
|
||||||
).toBeTruthy();
|
|
||||||
expect(
|
|
||||||
appTree.exists(
|
|
||||||
'apps/test-ui-app/src/app/another-cmp/another-cmp.stories.tsx'
|
|
||||||
)
|
|
||||||
).toBeTruthy();
|
).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -39,17 +35,13 @@ describe('react:stories for applications', () => {
|
|||||||
});
|
});
|
||||||
await storiesGenerator(appTree, {
|
await storiesGenerator(appTree, {
|
||||||
project: 'test-ui-app',
|
project: 'test-ui-app',
|
||||||
ignorePaths: ['apps/test-ui-app/src/app/**'],
|
ignorePaths: ['test-ui-app/src/app/**'],
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(appTree.exists('apps/test-ui-app/src/app/App.tsx')).toBeTruthy();
|
expect(appTree.exists('test-ui-app/src/app/App.tsx')).toBeTruthy();
|
||||||
|
expect(appTree.exists('test-ui-app/src/app/App.stories.tsx')).toBeFalsy();
|
||||||
expect(
|
expect(
|
||||||
appTree.exists('apps/test-ui-app/src/app/App.stories.tsx')
|
appTree.exists('test-ui-app/src/app/another-cmp/another-cmp.stories.tsx')
|
||||||
).toBeFalsy();
|
|
||||||
expect(
|
|
||||||
appTree.exists(
|
|
||||||
'apps/test-ui-app/src/app/another-cmp/another-cmp.stories.tsx'
|
|
||||||
)
|
|
||||||
).toBeFalsy();
|
).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -61,18 +53,14 @@ describe('react:stories for applications', () => {
|
|||||||
|
|
||||||
await storiesGenerator(appTree, {
|
await storiesGenerator(appTree, {
|
||||||
project: 'test-ui-app',
|
project: 'test-ui-app',
|
||||||
ignorePaths: [
|
ignorePaths: ['test-ui-app/src/app/another-new-cmp/another-new-cmp.tsx'],
|
||||||
'apps/test-ui-app/src/app/another-new-cmp/another-new-cmp.tsx',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(appTree.exists('apps/test-ui-app/src/app/App.tsx')).toBeTruthy();
|
expect(appTree.exists('test-ui-app/src/app/App.tsx')).toBeTruthy();
|
||||||
expect(
|
expect(appTree.exists('test-ui-app/src/app/App.stories.tsx')).toBeTruthy();
|
||||||
appTree.exists('apps/test-ui-app/src/app/App.stories.tsx')
|
|
||||||
).toBeTruthy();
|
|
||||||
expect(
|
expect(
|
||||||
appTree.exists(
|
appTree.exists(
|
||||||
'apps/test-ui-app/src/app/another-new-cmp/another-new-cmp.stories.tsx'
|
'test-ui-app/src/app/another-new-cmp/another-new-cmp.stories.tsx'
|
||||||
)
|
)
|
||||||
).toBeFalsy();
|
).toBeFalsy();
|
||||||
});
|
});
|
||||||
@ -89,23 +77,19 @@ describe('react:stories for applications', () => {
|
|||||||
});
|
});
|
||||||
await storiesGenerator(appTree, {
|
await storiesGenerator(appTree, {
|
||||||
project: 'test-ui-app',
|
project: 'test-ui-app',
|
||||||
ignorePaths: [
|
ignorePaths: ['test-ui-app/src/app/another-new-cmp/another-new-cmp.tsx'],
|
||||||
'apps/test-ui-app/src/app/another-new-cmp/another-new-cmp.tsx',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(appTree.exists('apps/test-ui-app/src/app/App.tsx')).toBeTruthy();
|
expect(appTree.exists('test-ui-app/src/app/App.tsx')).toBeTruthy();
|
||||||
expect(
|
expect(appTree.exists('test-ui-app/src/app/App.stories.tsx')).toBeTruthy();
|
||||||
appTree.exists('apps/test-ui-app/src/app/App.stories.tsx')
|
|
||||||
).toBeTruthy();
|
|
||||||
expect(
|
expect(
|
||||||
appTree.exists(
|
appTree.exists(
|
||||||
'apps/test-ui-app/src/app/another-new-cmp/comp-a/comp-a.stories.tsx'
|
'test-ui-app/src/app/another-new-cmp/comp-a/comp-a.stories.tsx'
|
||||||
)
|
)
|
||||||
).toBeTruthy();
|
).toBeTruthy();
|
||||||
expect(
|
expect(
|
||||||
appTree.exists(
|
appTree.exists(
|
||||||
'apps/test-ui-app/src/app/another-new-cmp/another-new-cmp.stories.tsx'
|
'test-ui-app/src/app/another-new-cmp/another-new-cmp.stories.tsx'
|
||||||
)
|
)
|
||||||
).toBeFalsy();
|
).toBeFalsy();
|
||||||
});
|
});
|
||||||
@ -113,7 +97,7 @@ describe('react:stories for applications', () => {
|
|||||||
it('should ignore files that do not contain components', async () => {
|
it('should ignore files that do not contain components', async () => {
|
||||||
// create another component
|
// create another component
|
||||||
appTree.write(
|
appTree.write(
|
||||||
'apps/test-ui-app/src/app/some-utils.js',
|
'test-ui-app/src/app/some-utils.js',
|
||||||
`export const add = (a: number, b: number) => a + b;`
|
`export const add = (a: number, b: number) => a + b;`
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -123,14 +107,12 @@ describe('react:stories for applications', () => {
|
|||||||
|
|
||||||
// should just create the story and not error, even though there's a js file
|
// should just create the story and not error, even though there's a js file
|
||||||
// not containing any react component
|
// not containing any react component
|
||||||
expect(
|
expect(appTree.exists('test-ui-app/src/app/App.stories.tsx')).toBeTruthy();
|
||||||
appTree.exists('apps/test-ui-app/src/app/App.stories.tsx')
|
|
||||||
).toBeTruthy();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
export async function createTestUIApp(libName: string): Promise<Tree> {
|
export async function createTestUIApp(libName: string): Promise<Tree> {
|
||||||
let appTree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
let appTree = createTreeWithEmptyWorkspace();
|
||||||
appTree.write('.gitignore', '');
|
appTree.write('.gitignore', '');
|
||||||
|
|
||||||
await applicationGenerator(appTree, {
|
await applicationGenerator(appTree, {
|
||||||
@ -140,6 +122,7 @@ export async function createTestUIApp(libName: string): Promise<Tree> {
|
|||||||
unitTestRunner: 'none',
|
unitTestRunner: 'none',
|
||||||
name: libName,
|
name: libName,
|
||||||
install: false,
|
install: false,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
return appTree;
|
return appTree;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,14 +27,10 @@ describe('react-native:stories for libraries', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
appTree.exists(
|
appTree.exists('test-ui-lib/src/lib/test-ui-lib/test-ui-lib.stories.tsx')
|
||||||
'libs/test-ui-lib/src/lib/test-ui-lib/test-ui-lib.stories.tsx'
|
|
||||||
)
|
|
||||||
).toBeTruthy();
|
).toBeTruthy();
|
||||||
expect(
|
expect(
|
||||||
appTree.exists(
|
appTree.exists('test-ui-lib/src/lib/another-cmp/another-cmp.stories.tsx')
|
||||||
'libs/test-ui-lib/src/lib/another-cmp/another-cmp.stories.tsx'
|
|
||||||
)
|
|
||||||
).toBeTruthy();
|
).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -49,18 +45,14 @@ describe('react-native:stories for libraries', () => {
|
|||||||
});
|
});
|
||||||
await storiesGenerator(appTree, {
|
await storiesGenerator(appTree, {
|
||||||
project: 'test-ui-lib',
|
project: 'test-ui-lib',
|
||||||
ignorePaths: ['libs/test-ui-lib/src/lib/another-cmp/**'],
|
ignorePaths: ['test-ui-lib/src/lib/another-cmp/**'],
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
appTree.exists(
|
appTree.exists('test-ui-lib/src/lib/test-ui-lib/test-ui-lib.stories.tsx')
|
||||||
'libs/test-ui-lib/src/lib/test-ui-lib/test-ui-lib.stories.tsx'
|
|
||||||
)
|
|
||||||
).toBeTruthy();
|
).toBeTruthy();
|
||||||
expect(
|
expect(
|
||||||
appTree.exists(
|
appTree.exists('test-ui-lib/src/lib/another-cmp/another-cmp.stories.tsx')
|
||||||
'libs/test-ui-lib/src/lib/another-cmp/another-cmp.stories.tsx'
|
|
||||||
)
|
|
||||||
).toBeFalsy();
|
).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -71,7 +63,7 @@ describe('react-native:stories for libraries', () => {
|
|||||||
});
|
});
|
||||||
// create another component
|
// create another component
|
||||||
appTree.write(
|
appTree.write(
|
||||||
'libs/test-ui-lib/src/lib/some-command-line-utils.ts',
|
'test-ui-lib/src/lib/some-command-line-utils.ts',
|
||||||
`export const add = (a: number, b: number) => a + b;`
|
`export const add = (a: number, b: number) => a + b;`
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -82,15 +74,13 @@ describe('react-native:stories for libraries', () => {
|
|||||||
// should just create the story and not error, even though there's a js file
|
// should just create the story and not error, even though there's a js file
|
||||||
// not containing any react component
|
// not containing any react component
|
||||||
expect(
|
expect(
|
||||||
appTree.exists(
|
appTree.exists('test-ui-lib/src/lib/test-ui-lib/test-ui-lib.stories.tsx')
|
||||||
'libs/test-ui-lib/src/lib/test-ui-lib/test-ui-lib.stories.tsx'
|
|
||||||
)
|
|
||||||
).toBeTruthy();
|
).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
export async function createTestUILib(libName: string): Promise<Tree> {
|
export async function createTestUILib(libName: string): Promise<Tree> {
|
||||||
let appTree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
let appTree = createTreeWithEmptyWorkspace();
|
||||||
appTree.write('.gitignore', '');
|
appTree.write('.gitignore', '');
|
||||||
|
|
||||||
await libraryGenerator(appTree, {
|
await libraryGenerator(appTree, {
|
||||||
@ -99,6 +89,7 @@ export async function createTestUILib(libName: string): Promise<Tree> {
|
|||||||
skipTsConfig: false,
|
skipTsConfig: false,
|
||||||
unitTestRunner: 'none',
|
unitTestRunner: 'none',
|
||||||
name: libName,
|
name: libName,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
|
|
||||||
await applicationGenerator(appTree, {
|
await applicationGenerator(appTree, {
|
||||||
@ -108,6 +99,7 @@ export async function createTestUILib(libName: string): Promise<Tree> {
|
|||||||
unitTestRunner: 'none',
|
unitTestRunner: 'none',
|
||||||
name: `${libName}-e2e`,
|
name: `${libName}-e2e`,
|
||||||
install: false,
|
install: false,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
return appTree;
|
return appTree;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,11 +36,9 @@ describe('react-native:storybook-configuration', () => {
|
|||||||
name: 'test-ui-lib',
|
name: 'test-ui-lib',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
expect(appTree.exists('test-ui-lib/.storybook/main.js')).toBeTruthy();
|
||||||
expect(
|
expect(
|
||||||
appTree.exists('libs/test-ui-lib/.storybook/main.js')
|
appTree.exists('test-ui-lib/tsconfig.storybook.json')
|
||||||
).toBeTruthy();
|
|
||||||
expect(
|
|
||||||
appTree.exists('libs/test-ui-lib/tsconfig.storybook.json')
|
|
||||||
).toBeTruthy();
|
).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -57,7 +55,7 @@ describe('react-native:storybook-configuration', () => {
|
|||||||
|
|
||||||
expect(
|
expect(
|
||||||
appTree.exists(
|
appTree.exists(
|
||||||
'libs/test-ui-lib/src/lib/test-ui-lib/test-ui-lib.stories.tsx'
|
'test-ui-lib/src/lib/test-ui-lib/test-ui-lib.stories.tsx'
|
||||||
)
|
)
|
||||||
).toBeTruthy();
|
).toBeTruthy();
|
||||||
});
|
});
|
||||||
@ -70,11 +68,9 @@ describe('react-native:storybook-configuration', () => {
|
|||||||
name: 'test-ui-app',
|
name: 'test-ui-app',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
expect(appTree.exists('test-ui-app/.storybook/main.js')).toBeTruthy();
|
||||||
expect(
|
expect(
|
||||||
appTree.exists('apps/test-ui-app/.storybook/main.js')
|
appTree.exists('test-ui-app/tsconfig.storybook.json')
|
||||||
).toBeTruthy();
|
|
||||||
expect(
|
|
||||||
appTree.exists('apps/test-ui-app/tsconfig.storybook.json')
|
|
||||||
).toBeTruthy();
|
).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -90,7 +86,7 @@ describe('react-native:storybook-configuration', () => {
|
|||||||
// under the specified 'lib' directory
|
// under the specified 'lib' directory
|
||||||
expect(
|
expect(
|
||||||
appTree.exists(
|
appTree.exists(
|
||||||
'apps/test-ui-app/src/app/my-component/my-component.stories.tsx'
|
'test-ui-app/src/app/my-component/my-component.stories.tsx'
|
||||||
)
|
)
|
||||||
).toBeTruthy();
|
).toBeTruthy();
|
||||||
});
|
});
|
||||||
@ -98,7 +94,7 @@ describe('react-native:storybook-configuration', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export async function createTestUILib(libName: string): Promise<Tree> {
|
export async function createTestUILib(libName: string): Promise<Tree> {
|
||||||
let appTree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
let appTree = createTreeWithEmptyWorkspace();
|
||||||
|
|
||||||
await libraryGenerator(appTree, {
|
await libraryGenerator(appTree, {
|
||||||
linter: Linter.EsLint,
|
linter: Linter.EsLint,
|
||||||
@ -106,6 +102,7 @@ export async function createTestUILib(libName: string): Promise<Tree> {
|
|||||||
skipTsConfig: false,
|
skipTsConfig: false,
|
||||||
unitTestRunner: 'none',
|
unitTestRunner: 'none',
|
||||||
name: libName,
|
name: libName,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
return appTree;
|
return appTree;
|
||||||
}
|
}
|
||||||
@ -114,7 +111,7 @@ export async function createTestAppLib(
|
|||||||
libName: string,
|
libName: string,
|
||||||
plainJS = false
|
plainJS = false
|
||||||
): Promise<Tree> {
|
): Promise<Tree> {
|
||||||
let appTree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
let appTree = createTreeWithEmptyWorkspace();
|
||||||
|
|
||||||
await applicationGenerator(appTree, {
|
await applicationGenerator(appTree, {
|
||||||
e2eTestRunner: 'none',
|
e2eTestRunner: 'none',
|
||||||
@ -125,6 +122,7 @@ export async function createTestAppLib(
|
|||||||
name: libName,
|
name: libName,
|
||||||
js: plainJS,
|
js: plainJS,
|
||||||
install: false,
|
install: false,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
|
|
||||||
await componentGenerator(appTree, {
|
await componentGenerator(appTree, {
|
||||||
|
|||||||
@ -9,17 +9,17 @@ describe('addResolverMainFieldsToMetroConfig', () => {
|
|||||||
let tree: Tree;
|
let tree: Tree;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
tree = createTreeWithEmptyWorkspace();
|
||||||
|
|
||||||
addProjectConfiguration(tree, 'products', {
|
addProjectConfiguration(tree, 'products', {
|
||||||
root: 'apps/products',
|
root: 'products',
|
||||||
sourceRoot: 'apps/products/src',
|
sourceRoot: 'products/src',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should update metro.config.js and add key projectRoot`, async () => {
|
it(`should update metro.config.js and add key projectRoot`, async () => {
|
||||||
tree.write(
|
tree.write(
|
||||||
'apps/products/metro.config.js',
|
'products/metro.config.js',
|
||||||
formatFile`
|
formatFile`
|
||||||
const { withNxMetro } = require('@nx/react-native');
|
const { withNxMetro } = require('@nx/react-native');
|
||||||
const { getDefaultConfig } = require('metro-config');
|
const { getDefaultConfig } = require('metro-config');
|
||||||
@ -55,7 +55,7 @@ module.exports = (async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
formatFile`${tree.read('apps/products/metro.config.js', 'utf-8')}`
|
formatFile`${tree.read('products/metro.config.js', 'utf-8')}`
|
||||||
).toEqual(
|
).toEqual(
|
||||||
formatFile`
|
formatFile`
|
||||||
const { withNxMetro } = require('@nx/react-native');
|
const { withNxMetro } = require('@nx/react-native');
|
||||||
@ -91,7 +91,7 @@ module.exports = (async () => {
|
|||||||
|
|
||||||
it(`should not udpate metro.config.js if projectRoot already exists`, async () => {
|
it(`should not udpate metro.config.js if projectRoot already exists`, async () => {
|
||||||
tree.write(
|
tree.write(
|
||||||
'apps/products/metro.config.js',
|
'products/metro.config.js',
|
||||||
`
|
`
|
||||||
const { withNxMetro } = require('@nx/react-native');
|
const { withNxMetro } = require('@nx/react-native');
|
||||||
const { getDefaultConfig } = require('metro-config');
|
const { getDefaultConfig } = require('metro-config');
|
||||||
@ -126,7 +126,7 @@ module.exports = (async () => {
|
|||||||
name: 'products',
|
name: 'products',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(tree.read('apps/products/metro.config.js', 'utf-8')).toEqual(
|
expect(tree.read('products/metro.config.js', 'utf-8')).toEqual(
|
||||||
`
|
`
|
||||||
const { withNxMetro } = require('@nx/react-native');
|
const { withNxMetro } = require('@nx/react-native');
|
||||||
const { getDefaultConfig } = require('metro-config');
|
const { getDefaultConfig } = require('metro-config');
|
||||||
|
|||||||
@ -9,17 +9,17 @@ describe('replaceAppImportWithStorybookToggle', () => {
|
|||||||
let tree: Tree;
|
let tree: Tree;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
tree = createTreeWithEmptyWorkspace();
|
||||||
|
|
||||||
addProjectConfiguration(tree, 'products', {
|
addProjectConfiguration(tree, 'products', {
|
||||||
root: 'apps/products',
|
root: 'products',
|
||||||
sourceRoot: 'apps/products/src',
|
sourceRoot: 'products/src',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update the main file with import from storybook', async () => {
|
it('should update the main file with import from storybook', async () => {
|
||||||
tree.write(
|
tree.write(
|
||||||
'/apps/products/src/main.tsx',
|
'products/src/main.tsx',
|
||||||
formatFile`import { AppRegistry } from 'react-native';
|
formatFile`import { AppRegistry } from 'react-native';
|
||||||
import App from './app/App';
|
import App from './app/App';
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ describe('replaceAppImportWithStorybookToggle', () => {
|
|||||||
js: false,
|
js: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const mainFile = tree.read('apps/products/src/main.tsx', 'utf-8');
|
const mainFile = tree.read('products/src/main.tsx', 'utf-8');
|
||||||
expect(formatFile`${mainFile}`).toEqual(
|
expect(formatFile`${mainFile}`).toEqual(
|
||||||
formatFile`import { AppRegistry } from 'react-native';
|
formatFile`import { AppRegistry } from 'react-native';
|
||||||
import App from './storybook/toggle-storybook';
|
import App from './storybook/toggle-storybook';
|
||||||
@ -42,7 +42,7 @@ describe('replaceAppImportWithStorybookToggle', () => {
|
|||||||
|
|
||||||
it('should not update the main file if import is already updated', async () => {
|
it('should not update the main file if import is already updated', async () => {
|
||||||
tree.write(
|
tree.write(
|
||||||
'/apps/products/src/main.tsx',
|
'products/src/main.tsx',
|
||||||
formatFile`import { AppRegistry } from 'react-native';
|
formatFile`import { AppRegistry } from 'react-native';
|
||||||
import App from './app/App';
|
import App from './app/App';
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ describe('replaceAppImportWithStorybookToggle', () => {
|
|||||||
js: false,
|
js: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const mainFile = tree.read('apps/products/src/main.tsx', 'utf-8');
|
const mainFile = tree.read('products/src/main.tsx', 'utf-8');
|
||||||
expect(formatFile`${mainFile}`).toEqual(
|
expect(formatFile`${mainFile}`).toEqual(
|
||||||
formatFile`import { AppRegistry } from 'react-native';
|
formatFile`import { AppRegistry } from 'react-native';
|
||||||
import App from './storybook/toggle-storybook';
|
import App from './storybook/toggle-storybook';
|
||||||
|
|||||||
@ -11,19 +11,20 @@ export async function createApp(tree: Tree, appName: string): Promise<void> {
|
|||||||
name: appName,
|
name: appName,
|
||||||
e2eTestRunner: 'none',
|
e2eTestRunner: 'none',
|
||||||
install: false,
|
install: false,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createLib(tree: Tree, libName: string): Promise<void> {
|
export async function createLib(tree: Tree, libName: string): Promise<void> {
|
||||||
const { fileName } = names(libName);
|
const { fileName } = names(libName);
|
||||||
|
|
||||||
tree.write(`/libs/${fileName}/src/index.ts`, `import React from 'react';\n`);
|
tree.write(`${fileName}/src/index.ts`, `import React from 'react';\n`);
|
||||||
|
|
||||||
addProjectConfiguration(tree, fileName, {
|
addProjectConfiguration(tree, fileName, {
|
||||||
tags: [],
|
tags: [],
|
||||||
root: `libs/${fileName}`,
|
root: `${fileName}`,
|
||||||
projectType: 'library',
|
projectType: 'library',
|
||||||
sourceRoot: `libs/${fileName}/src`,
|
sourceRoot: `${fileName}/src`,
|
||||||
targets: {},
|
targets: {},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user