{"id":28577195,"url":"https://github.com/op-engineering/op-test","last_synced_at":"2026-02-19T14:30:58.358Z","repository":{"id":275727067,"uuid":"926994804","full_name":"OP-Engineering/op-test","owner":"OP-Engineering","description":"Simple in-app testing framework for React Native","archived":false,"fork":false,"pushed_at":"2025-09-07T13:23:55.000Z","size":9678,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-07T15:20:04.727Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OP-Engineering.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-04T08:13:42.000Z","updated_at":"2025-09-07T13:23:58.000Z","dependencies_parsed_at":"2025-09-07T15:22:44.354Z","dependency_job_id":null,"html_url":"https://github.com/OP-Engineering/op-test","commit_stats":null,"previous_names":["op-engineering/op-test"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/OP-Engineering/op-test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OP-Engineering%2Fop-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OP-Engineering%2Fop-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OP-Engineering%2Fop-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OP-Engineering%2Fop-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OP-Engineering","download_url":"https://codeload.github.com/OP-Engineering/op-test/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OP-Engineering%2Fop-test/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29618220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T13:04:20.082Z","status":"ssl_error","status_checked_at":"2026-02-19T13:03:33.775Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-11T00:30:27.083Z","updated_at":"2026-02-19T14:30:58.330Z","avatar_url":"https://github.com/OP-Engineering.png","language":"TypeScript","readme":"# op-test\n\nA lightweight, in-app testing framework for React Native applications.\n\n## Motivation\n\nYou can think of op-test as a half-way between a Detox (UI e2e test) and Jest (runs in a Node environment). It's specially useful for library authors that depend on native libraries or some sort of runtime behavior that requires a simulator/emulator/device to assert correct functionality. It's specially suited to test JSI enabled libraries as testing JSI/TurboModules/NitroModules functions require the whole the React Native app to have started.\n\n![Screenshot of test results](./screenshot.png)\n\n## Installation\n\n```sh\nnpm install --save @op-engineering/op-test\n```\n\n## Usage\n\nImport the testing utilities and write your tests:\n\n```tsx\nimport { describe, it, expect } from '@op-engineering/op-test';\n\ndescribe('Example', () =\u003e {\n  it('should work', () =\u003e {\n    expect(1 + 1).toBe(2);\n  });\n});\n```\n\nYou can then call the `runTests` function which will run all the functions registered under the `describe` blocks:\n\n```ts\nimport {runTests} from '@op-engineering/op-test`;\n\nconst results = await runTests()\n```\n\n### Available Functions\n\n- `describe(name: string, fn: () =\u003e void)`: Group related tests\n- `it(name: string, fn: TestFunction)`: Define a test case\n- `expect(value)`: Create assertions with:\n  - `.toBe(expected)`: Strict equality\n  - `.toEqual(expected)`: Loose equality\n  - `.not.toBe(expected)`: Negative strict equality\n  - `.not.toEqual(expected)`: Negative loose equality\n  - `.resolves`: For testing promises\n  - `.rejects`: For testing promise rejections\n\n### Hooks\n\n- `beforeAll(fn)`: Run before all tests in a describe block\n- `beforeEach(fn)`: Run before each test\n- `afterAll(fn)`: Run after all tests in a describe block\n- `afterEach(fn)`: Run after each test\n\n### Display Results\n\nUse the `displayResults` component to show test results in your app in a visual way:\n\n```tsx\nimport { runTests, displayResults } from '@op-engineering/op-test';\n\nexport default function App() {\n  const [result, setResult] = useState(null);\n\n  useEffect(() =\u003e {\n    runTests().then(setResult);\n  }, []);\n\n  return displayResults(result);\n}\n```\n\n### CI\n\nYou probably want to automate your in-app tests in your CI. For this you can pass the DescribeBlock to the `allTestsPassed` function, it will return a boolean that indicates if all tests have passed. You can this automate this in various ways in your CI. My favorite is starting and in-app http server, exposing a single endpoint. From your CI you can then start the app, query this endpoint (over and over until it returns a reponse). Here is a snippet how to do this.\n\nServer code:\n\n```ts\nimport { BridgeServer } from 'react-native-http-bridge-refurbished';\n\nlet testsPassed: boolean | null = null;\n\nconst server = new BridgeServer('http_service', true);\n\nserver.get('/ping', async (_req, _res) =\u003e {\n  return { message: 'pong' };\n});\n\nserver.get('/results', async (_req, _res) =\u003e {\n  return { testPassed };\n});\n\nserver.listen(9000);\n\nexport function startServer() {\n  return server;\n}\n\nexport function stopServer() {\n  server.stop();\n}\n\nexport function setServerTestPassed(r: boolean) {\n  testsPassed = r;\n}\n```\n\nThen to run your tests:\n\n```tsx\nimport {\n  runTests,\n  displayResults,\n  allTestsPassed,\n} from '@op-engineering/op-test';\nimport { startServer, setServerTestPassed } from './server';\n\nexport default function App() {\n  const [result, setResult] = useState(null);\n\n  useEffect(() =\u003e {\n    runTests().then((newResults) =\u003e {\n      setServerTestPassed(allTestsPassed(newResults));\n      setResult(newResults);\n    });\n\n    startServer();\n  }, []);\n\n  return displayResults(result);\n}\n```\n\nThe CI code is left as an exercise to the reader, just curl the device ip until you get a response.\n\n## License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fop-engineering%2Fop-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fop-engineering%2Fop-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fop-engineering%2Fop-test/lists"}