From 526cc810e2980b916c2a9ea528d95e1cef3e8791 Mon Sep 17 00:00:00 2001 From: Matt Wynne Date: Wed, 1 Dec 2021 08:48:14 -0800 Subject: [PATCH] Add a warning for Windows developers The tests won't work if you don't have "Developer Mode" enabled. See #1852 Co-authored-by: Aurelien Reeves --- features/support/hooks.ts | 7 +++++- ...warn_user_about_enabling_developer_mode.ts | 25 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 features/support/warn_user_about_enabling_developer_mode.ts diff --git a/features/support/hooks.ts b/features/support/hooks.ts index 650a50ee4..686822fbf 100644 --- a/features/support/hooks.ts +++ b/features/support/hooks.ts @@ -6,6 +6,7 @@ import tmp from 'tmp' import { doesHaveValue } from '../../src/value_checker' import { World } from './world' import { ITestCaseHookParameter } from '../../src/support_code_library_builder/types' +import { warnUserAboutEnablingDeveloperMode } from './warn_user_about_enabling_developer_mode' const projectPath = path.join(__dirname, '..', '..') @@ -39,7 +40,11 @@ Before(function ( '@cucumber', 'cucumber' ) - fsExtra.ensureSymlinkSync(projectPath, tmpDirCucumberPath) + try { + fsExtra.ensureSymlinkSync(projectPath, tmpDirCucumberPath) + } catch (error) { + warnUserAboutEnablingDeveloperMode(error) + } this.localExecutablePath = path.join(projectPath, 'bin', 'cucumber-js') }) diff --git a/features/support/warn_user_about_enabling_developer_mode.ts b/features/support/warn_user_about_enabling_developer_mode.ts new file mode 100644 index 000000000..9afcd37a7 --- /dev/null +++ b/features/support/warn_user_about_enabling_developer_mode.ts @@ -0,0 +1,25 @@ +import { reindent } from 'reindent-template-literals' +import colors from 'colors/safe' + +export function warnUserAboutEnablingDeveloperMode(error: any): void { + if (!(error?.code === 'EPERM')) { + throw error + } + if (!(process.platform === 'win32')) { + throw error + } + + console.error( + colors.red( + reindent(` + Error: Unable to run feature tests! + + You need to enable Developer Mode in Windows to run Cucumber JS's feature tests. + + See this link for more info: + https://docs.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging + `) + ) + ) + process.exit(1) +}