All files / libs/tools/plugin/src/generators/heal/healthpacks cypress-config.ts

94.28% Statements 33/35
80% Branches 4/5
100% Functions 1/1
94.28% Lines 33/35

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 361x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 17x 17x     17x 17x 17x 13x 13x 4x 4x 17x 4x 4x 4x 4x 4x 4x 4x 4x 4x  
import { join } from 'node:path';
 
import { generateFiles, offsetFromRoot, type ProjectConfiguration, type Tree } from '@nx/devkit';
 
export type ExpectedEslintRc = {
  overrides: [
    {
      files: string[];
      rules: Record<string, string>;
    },
  ];
};
 
export const updateCypressConfiguration = (tree: Tree, projectConfiguration: ProjectConfiguration) => {
  // Only libs
  if (projectConfiguration.projectType !== 'library') {
    return;
  }
 
  // Only cypress
  if (!tree.exists(`${projectConfiguration.root}/cypress.config.ts`)) {
    return;
  }
 
  // Remove "configurations" from e2e target - use default ones from nx.json
  if (projectConfiguration.targets?.['e2e']) {
    delete projectConfiguration.targets['e2e'];
  }
 
  // Overwrite cypress, tsconfig and eslint configuration files.
  generateFiles(tree, join(__dirname, '..', 'files', 'cypress-config'), projectConfiguration.root, {
    offsetFromRoot: offsetFromRoot(projectConfiguration.root),
    projectRoot: projectConfiguration.root,
  });
};