import injectDevServer from '@cypress/react/plugins/babel' ; import injectCodeCoverage from '@cypress/code-coverage/task' ; import path from 'path' ; import { RuleSetRule } from 'webpack' ; export default ( on , config ) : Cypress . ResolvedConfigOptions => { if ( config . testingType === 'component' ) { injectDevServer ( on , config , { setWebpackConfig : ( webpackConfig ) => { const isProductionSmokeTest = process . env . BABEL_ENV === 'production' ; const componentDirectoryName = isProductionSmokeTest ? 'dist' : 'src' ; webpackConfig . resolve . alias = { 'react-hover-video-player' : path . resolve ( __dirname , `../../../${ componentDirectoryName }` ) , } ; webpackConfig . module . rules . forEach ( ( webpackRule ) => { if ( webpackRule ?. loader === 'babel-loader' ) { webpackRule . options = { presets : [ '@babel/preset-env' , '@babel/preset-typescript' , '@babel/preset-react' , ] , plugins : [ 'istanbul' ] , } ; } } ) ; return webpackConfig ; } , } ) ; } injectCodeCoverage ( on , config ) ; on ( 'before:browser:launch' , ( browser , launchOptions ) => { const autoplayPolicyOptionIndex = launchOptions . args . indexOf ( '--autoplay-policy=no-user-gesture-required' ) ; if ( autoplayPolicyOptionIndex >= 0 ) { launchOptions . args [ autoplayPolicyOptionIndex ] = '--disable-features=PreloadMediaEngagementData, MediaEngagementBypassAutoplayPolicies' ; } return launchOptions ; } ) ; return config ; } ;