import { stripIndent } from "common-tags"; import { FileWriter } from "../../base"; import { IFileWriter, TFileWriterConfig } from "../../types"; import { GlobalHelpers } from "../../../helpers"; class AutomatedTestsUtilityFunctionsWriter extends FileWriter implements IFileWriter { constructor(protected config: TFileWriterConfig) { super(config); } getFileContent() { const fileContent = stripIndent` import React from "react"; import Enzyme,{ shallow } from "enzyme"; import Adapter from 'enzyme-adapter-react-16'; import 'jest-enzyme'; Enzyme.configure({ adapter: new Adapter() }); export const findByTestAttrWeb = ({wrapper, attribute}) => wrapper.find('[data-test="'+attribute+'"]'); export const findElementByAttrNative=({wrapper,attribute:testID})=>wrapper.findWhere(node => node.prop('testID') === testID); export const setupComponent = ({component:Component, props = {}}) =>shallow(); `; return fileContent; } execute() { try { this.write('wx'); } catch (error) { GlobalHelpers.showError(error); } } } export { AutomatedTestsUtilityFunctionsWriter };