nx/packages/react/src/generators/cypress-component-configuration/cypress-component-configuration.ts
Caleb Ukle c7249db386
fix(testing): handle more complex projects for react component testing (#11725)
* fix(testing): use @nrwl/web:webpack utils to generate a more robust webpack config

fixes: #11372

* fix(testing): do not overwrite existing component test

* fix(testing): add component-test to cacheable operations

* chore(testing): address pr feedback
2022-08-30 16:42:42 +00:00

35 lines
1.0 KiB
TypeScript

import { cypressComponentProject } from '@nrwl/cypress';
import { formatFiles, readProjectConfiguration, Tree } from '@nrwl/devkit';
import { addFiles } from './lib/add-files';
import { updateProjectConfig, updateTsConfig } from './lib/update-configs';
import { CypressComponentConfigurationSchema } from './schema.d';
/**
* This is for using cypresses own Component testing, if you want to use test
* storybook components then use componentCypressGenerator instead.
*
*/
export async function cypressComponentConfigGenerator(
tree: Tree,
options: CypressComponentConfigurationSchema
) {
const projectConfig = readProjectConfiguration(tree, options.project);
const installTask = await cypressComponentProject(tree, {
project: options.project,
skipFormat: true,
});
await updateProjectConfig(tree, options);
addFiles(tree, projectConfig, options);
updateTsConfig(tree, projectConfig);
if (options.skipFormat) {
await formatFiles(tree);
}
return () => {
installTask();
};
}
export default cypressComponentConfigGenerator;