---
title: "Serhiy Tymoshenko (@sergtimosh) | Hashnode"
description: "Serhiy Tymoshenko (@sergtimosh) writes on Hashnode. Read their latest articles and follow their work."
url: "https://hashnode.com/@sergtimosh"
---

@sergtimosh

# Serhiy Tymoshenko

@sergtimosh · Joined September 2022

## Comments

[Hugh McCamphill Yes, I see that :) But it's still a question for me where and how do you expose jestExpect to already use in this block? I am lacking infrastructure understanding for that purpose To use jestExpect instead of the expect exposed by detox I have to import it explicitly. Also I see the issue with toMatchImage not available in the methods scope after been extended to. import { configureToMatchImageSnapshot } from 'jest-image-snapshot'; import fs from 'fs'; import path from 'path'; import kebabCase from 'lodash.kebabcase'; import jestExpect from 'expect' const toMatchImage = configureToMatchImageSnapshot({ comparisonMethod: 'ssim', failureThreshold: 0.002, failureThresholdType: 'percent' }); jestExpect.extend({ toMatchImage }); jestExpect.extend({ async toMatchImageSnapshot(screenName) { const platform = device.getPlatform(); const deviceName = device.name.split(' ').slice(1).join(''); const deviceType = JSON.parse(deviceName).type.replace(',',''); const SNAPSHOTS\_DIR = \`\_\_image\_snapshots\_\_/${platform}/${deviceType}\`; const { testPath, currentTestName } = this; const customSnapshotsDir = path.join(path.dirname(testPath), SNAPSHOTS\_DIR); const customSnapshotIdentifier = kebabCase(\`${path.basename(testPath)}-${currentTestName}-${screenName}\`) const tempPath = await device.takeScreenshot(screenName); const image = fs.readFileSync(tempPath); jestExpect(image).toMatchImage({ customSnapshotIdentifier, customSnapshotsDir }); ~~~~~~~~~~~ return { pass: true } }, }); global.jestExpect = jestExpect](https://hashnode.com/posts/visual-regression-testing-react-native-apps-with-detox-and-jest/62081c2ba2be760e35396a8c/comment/6333353cfa20fa4bc8e5044b#reply-6333f81cfa20fa4bc8e51171)

Reply · Article · Sep 28, 2022 · [Visual regression testing React Native apps with Detox and Jest](https://hashnode.com/posts/visual-regression-testing-react-native-apps-with-detox-and-jest/62081c2ba2be760e35396a8c)

[Thanks a lot for the idea and the article! Could you please elaborate more on Extend jest expect part? Didn't quite get how do you expose this jest extension helper to the tests? Maybe you have some public repo to share the structure and configuration? Thanks in advance!](https://hashnode.com/posts/visual-regression-testing-react-native-apps-with-detox-and-jest/62081c2ba2be760e35396a8c/comment/6333353cfa20fa4bc8e5044b)

Comment · Article · Sep 27, 2022 · [Visual regression testing React Native apps with Detox and Jest](https://hashnode.com/posts/visual-regression-testing-react-native-apps-with-detox-and-jest/62081c2ba2be760e35396a8c)
