-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(common-steps): updated the template to stub the file system in t…
…he `Before` step
- Loading branch information
Showing
1 changed file
with
10 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
import {dirname, resolve} from 'node:path'; | ||
import {fileURLToPath} from 'node:url'; | ||
|
||
import {After, When} from '@cucumber/cucumber'; | ||
import {After, Before When} from '@cucumber/cucumber'; | ||
import stubbedFs from 'mock-fs'; | ||
|
||
const __dirname = dirname(fileURLToPath(import.meta.url)); // eslint-disable-line no-underscore-dangle | ||
const stubbedNodeModules = stubbedFs.load(resolve(__dirname, '..', '..', '..', '..', 'node_modules')); | ||
|
||
After(function () { | ||
stubbedFs.restore(); | ||
}); | ||
let scaffold; | ||
|
||
When('the project is scaffolded', async function () { | ||
Before(function () { | ||
// eslint-disable-next-line import/no-extraneous-dependencies,import/no-unresolved | ||
const {scaffold} = await import('{{{ packageName }}}'); | ||
({scaffold} = await import('{{{ packageName }}}')); | ||
|
||
stubbedFs({ | ||
node_modules: stubbedNodeModules | ||
}); | ||
}); | ||
|
||
After(function () { | ||
stubbedFs.restore(); | ||
}); | ||
|
||
When('the project is scaffolded', async function () { | ||
await scaffold({projectRoot: process.cwd()}); | ||
}); |