From 42ab498888d82b31122c8529740bc37ea18665da Mon Sep 17 00:00:00 2001 From: Matt Travi Date: Tue, 26 Dec 2023 00:01:16 -0500 Subject: [PATCH] feat(common-steps): updated the template to stub the file system in the `Before` step --- templates/common-steps.mustache | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/templates/common-steps.mustache b/templates/common-steps.mustache index 97a4a1d3..b8bd3a6b 100644 --- a/templates/common-steps.mustache +++ b/templates/common-steps.mustache @@ -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()}); });