import { copyFile } from 'fs-extra' import { packageJson } from 'mrm-core' interface TaskConfig { enableEmotion: boolean } const testingTask: TaskExecution = async ({ getTargetPath, getTaskPath, installYarn, taskConfig, }) => { packageJson() .setScript('test', 'react-scripts test --verbose=false') .setScript( 'testAll', 'cross-env CI=1 react-scripts test --onlyChanged=false', ) .save() const packages = { '@speedlo/testing': '1.x', '@testing-library/jest-dom': '4.x', '@testing-library/react': '9.x', '@testing-library/react-hooks': '2.x', '@types/jest': '24.x', '@types/jest-in-case': '1.x', 'error-stack-parser': '2.x', 'jest-in-case': '1.x', 'jest-mock-console': '1.x', 'react-test-renderer': '>=16.8', 'test-data-bot': '^0.8', } if (taskConfig.enableEmotion === true) { packages['jest-emotion'] = '9.x' } await installYarn(packages) await copyFile( getTaskPath('setupTests.js'), getTargetPath('src/setupTests.js'), ) } testingTask.description = 'Add support packages for testing' export default testingTask