jest icon indicating copy to clipboard operation
jest copied to clipboard

[Feature]: setupExec and teardownExec

Open xenoterracide opened this issue 3 years ago • 1 comments

🚀 Feature Proposal

I'd like a setupExec, setupExecAfterEnv and teardownExec that can run arbitrary commands added to the config parameters

Motivation

For integration testing servers may need to be started and stopped, this can be accomplished with setupFiles* currently, however it takes quite a bit of effort. In my case I spent half a day figuring out how to get a wait-for.sh replacement, and the ability to run a yarn command as well as write my setup files in typescript.

Example

instead of in the projects array

    {
      displayName: 'integration',
      testMatch: ['<rootDir>/**/test/integration/**/*.test.ts'],
      runner: 'jest-runner',
      transform: tsjPreset.transform,
      setupFilesAfterEnv: ['./jest/dist/serve.js', './jest/dist/wait-for.js'],
    },
    {
      displayName: 'integration',
      testMatch: ['<rootDir>/**/test/integration/**/*.test.ts'],
      runner: 'jest-runner',
      transform: tsjPreset.transform,
      setupExecAfterEnv: ['yarn serve', './wait-for.sh'],
    },

Pitch

I can only imagine setting up and tearing down servers is very common, this also helps IDE's run integration tests without developers remembering to start servers.

xenoterracide avatar Aug 09 '22 19:08 xenoterracide

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Sep 08 '22 19:09 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

github-actions[bot] avatar Oct 08 '22 20:10 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

github-actions[bot] avatar Oct 08 '22 20:10 github-actions[bot]

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

github-actions[bot] avatar Nov 08 '22 00:11 github-actions[bot]