Skip to content

[🐛 Bug]: Install of WDIO into parent folder breaks existing tests and future installs [See Video] #11581

@darkartswizard

Description

@darkartswizard

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

8.3.4

Node.js Version

18.17.1

Mode

Standalone Mode

Which capabilities are you using?

Default.

What happened?

This issue is replicated in this private video.
WDIO Install in Parent Directory Breaks Tests and Future Installs

Scenario:
A new WDIO User creates a folder for their first project with a successful WDIO install.
The User runs the sample sample test run and it Passes.

The User realizes there will be multiple projects.
The User creates an organizational subset of folders for Project1 and Project2.
The User installs WDIO in the Project1 with Success.
The User is unaware it is using the node_modules and package.json from the parent \projects folder.
The User runs the Project1 sample test run and it Passes.

The User installs WDIO in the second project2 - The install FAILS.
The User re-runs the first Project1 test, which now FAILS.
The User re-runs the Parent project test, which also now FAILS.

Result: The User is frustrated with WDIO and leaves a 1-star Yelp review.

STEPS TO REPRODUCE - Create a parent directory for multiple sub-folder WDIO projects:

  1. Create parent directory named \projects
    Navigate to \projects from a console.
    Create child directory \project1
    Navigate to \projects\project1 from a console.
    Perform a default install in \project1: npm init wdio .
    EXPECTED RESULT 1: The install succeeds
    ACTUAL RESULT 1: PASS the install succeeds

  2. Run the sample Login test in \project1: npm run wdio
    EXPECTED RESULT 2: The test Passes
    ACTUAL RESULT 2: The test Passes

  3. Navigate to parent \projects directory
    Perform a default install in \projects: npm init wdio .
    Note: This is a common initial mistake a new WDIO user could make with problems arising only when then try to create their 2nd sub-project.

  4. Run the sample Login test from \projects: npm run wdio
    EXPECTED RESULT 3: The test Passes
    ACTUAL RESULT 3: The test Passes

  5. Create a sub-directory \projects\project2
    Navigate to project2 from a console.
    Perform a default install in \projects\project2: npm init wdio .
    Note: project2 install will find and use the parent files for node_modules and package.json
    EXPECTED RESULT 4: The install succeeds
    ACTUAL RESULT 4: PASS the install succeeds

  6. Run the sample Login test from project2: npm run wdio
    EXPECTED RESULT 5: The test Passes
    ACTUAL RESULT 5: The test Passes

  7. Create another sub-directory \projects\project3
    Navigate to \projects\project3 from a console.
    Perform a default install in \project3: npm init wdio .
    EXPECTED RESULT 6: the install succeeds
    ACTUAL RESULT 6: The install FAILS. No test sample test can be run

  8. Run the sample Login test from \projects\project3: npm run wdio
    EXPECTED RESULT 7: The test Passes
    ACTUAL RESULT 7: The test was never created and can not be run

  9. Run the sample Login test from project2: npm run wdio
    EXPECTED RESULT 8: The test Passes
    ACTUAL RESULT 8: The test now FAILS

  10. Run the sample Login test from parent folder projects: npm run wdio
    EXPECTED RESULT 9: The test Passes
    ACTUAL RESULT 9: The test now FAILS

  11. Run the sample Login test from \projects\project1 folder projects: npm run wdio
    EXPECTED RESULT 10: The test Passes
    ACTUAL RESULT 10: The test still passes, having it's own node_modules and package.json as it was created before Step 3.

What is your expected behavior?

  1. Install in 2nd, 3rd, etc child folders should be successful.
  2. Prior successful install runs should not be compromised.

Recommendation: If a parent path is detected, the Wizard should offer the User an option to use it.
Default should be to ignore it to avoid corrupting other projects.

How to reproduce the bug.

This issue is replicated in this private video.
WDIO Install in Parent Directory Breaks Tests and Future Installs

Scenario:
A new WDIO User creates a folder for their first project with a successful WDIO install.
The User runs the sample sample test run and it Passes.

The User realizes there will be multiple projects.
The User creates an organizational subset of folders for Project1 and Project2.
The User installs WDIO in the Project1 with Success.
The User is unaware it is using the node_modules and package.json from the parent \projects folder.
The User runs the Project1 sample test run and it Passes.

The User installs WDIO in the second project2 - The install FAILS.
The User re-runs the first Project1 test, which now FAILS.
The User re-runs the Parent project test, which also now FAILS.

Result: The User is frustrated with WDIO and leaves a 1-star Yelp review.

STEPS TO REPRODUCE - Create a parent directory for multiple sub-folder WDIO projects:

  1. Create parent directory named \projects
    Navigate to \projects from a console.
    Create child directory \project1
    Navigate to \projects\project1 from a console.
    Perform a default install in \project1: npm init wdio .
    EXPECTED RESULT 1: The install succeeds
    ACTUAL RESULT 1: PASS the install succeeds

  2. Run the sample Login test in \project1: npm run wdio
    EXPECTED RESULT 2: The test Passes
    ACTUAL RESULT 2: The test Passes

  3. Navigate to parent \projects directory
    Perform a default install in \projects: npm init wdio .
    Note: This is a common initial mistake a new WDIO user could make with problems arising only when then try to create their 2nd sub-project.

  4. Run the sample Login test from \projects: npm run wdio
    EXPECTED RESULT 3: The test Passes
    ACTUAL RESULT 3: The test Passes

  5. Create a sub-directory \projects\project2
    Navigate to project2 from a console.
    Perform a default install in \projects\project2: npm init wdio .
    Note: project2 install will find and use the parent files for node_modules and package.json
    EXPECTED RESULT 4: The install succeeds
    ACTUAL RESULT 4: PASS the install succeeds

  6. Run the sample Login test from project2: npm run wdio
    EXPECTED RESULT 5: The test Passes
    ACTUAL RESULT 5: The test Passes

  7. Create another sub-directory \projects\project3
    Navigate to \projects\project3 from a console.
    Perform a default install in \project3: npm init wdio .
    EXPECTED RESULT 6: the install succeeds
    ACTUAL RESULT 6: The install FAILS. No test sample test can be run

  8. Run the sample Login test from \projects\project3: npm run wdio
    EXPECTED RESULT 7: The test Passes
    ACTUAL RESULT 7: The test was never created and can not be run

  9. Run the sample Login test from project2: npm run wdio
    EXPECTED RESULT 8: The test Passes
    ACTUAL RESULT 8: The test now FAILS

  10. Run the sample Login test from parent folder projects: npm run wdio
    EXPECTED RESULT 9: The test Passes
    ACTUAL RESULT 9: The test now FAILS

  11. Run the sample Login test from \projects\project1 folder projects: npm run wdio
    EXPECTED RESULT 10: The test Passes
    ACTUAL RESULT 10: The test still passes, having it's own node_modules and package.json as it was created before Step 3.

Relevant log output

This is the console output from the failed install of project3 
and the failed output log of the failed project2 run that passed previously. 

--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------

OUTPUT #1
qtpmg@MSI_Mach2 MINGW64 /c/projects/project3
$ yarn create wdio .
yarn create v1.22.19
warning package.json: No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "create-wdio@8.3.4" with binaries:
      - create-wdio

                 -:...........................-:.
                 +                              +
              `` +      `...`        `...`      + `
            ./+/ +    .:://:::`    `::///::`  ` + ++/.
           .+oo+ +    /:+ooo+-/    /-+ooo+-/ ./ + +oo+.
           -ooo+ +    /-+ooo+-/    /-+ooo+-/ .: + +ooo.
            -+o+ +    `::///:-`    `::///::`    + +o+-
             ``. /.     ``        `````     .: .``
                  .----------------------------.
           `-::::::::::::::::::::::::::::::::::::::::-`
          .+oooo/:------------------------------:/oooo+.
      `.--/oooo-                                  :oooo/--.`
    .::-``:oooo`                                  .oooo-``-::.
  ./-`    -oooo`--.: :.--                         .oooo-    `-/.
 -/`    `-/oooo////////////////////////////////////oooo/.`    `/-
`+`   `/+oooooooooooooooooooooooooooooooooooooooooooooooo+:`   .+`
-/    +o/.:oooooooooooooooooooooooooooooooooooooooooooo:-/o/    +.
-/   .o+  -oooosoooososssssooooo------------------:oooo- `oo`   +.
-/   .o+  -oooodooohyyssosshoooo`                 .oooo-  oo.   +.
-/   .o+  -oooodooysdooooooyyooo` `.--.``     .:::-oooo-  oo.   +.
-/   .o+  -oooodoyyodsoooooyyooo.//-..-:/:.`.//.`./oooo-  oo.   +.
-/   .o+  -oooohsyoooyysssysoooo+-`     `-:::.    .oooo-  oo.   +.
-/   .o+  -ooooosooooooosooooooo+//////////////////oooo-  oo.   +.
-/   .o+  -oooooooooooooooooooooooooooooooooooooooooooo-  oo.   +.
-/   .o+  -oooooooooooooooooooooooooooooooooooooooooooo-  oo.   +.
-+////o+` -oooo---:///:----://::------------------:oooo- `oo////+-
+ooooooo/`-oooo``:-```.:`.:.`.+/-    .::::::::::` .oooo-`+ooooooo+
oooooooo+`-oooo`-- `/` .:+  -/-`/`   .::::::::::  .oooo-.+oooooooo
+-/+://-/ -oooo-`:`.o-`:.:-````.:    .///:``````  -oooo-`/-//:+:-+
: :..--:-:.+ooo+/://o+/-.-:////:-....-::::-....--/+ooo+.:.:--.-- /
- /./`-:-` .:///+/ooooo/+///////////////+++ooooo/+///:. .-:.`+./ :
:-:/.           :`ooooo`/`              .:.ooooo :           ./---
                :`ooooo`/`              .:.ooooo :
                :`ooooo./`              .:-ooooo :
                :`ooooo./`              .:-ooooo :
            `...:-+++++:/.              ./:+++++-:...`
           :-.````````/../              /.-:````````.:-
          -/::::::::://:/+             `+/:+::::::::::+.
          :oooooooooooo++/              +++oooooooooooo-

                           Webdriver.IO
              Next-gen browser and mobile automation
                    test framework for Node.js


Installing @wdio/cli to initialize project...
✔ Success!
C:\projects\node_modules\string-width\index.js:2
const stripAnsi = require('strip-ansi');
                  ^

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\projects\node_modules\strip-ansi\index.js from C:\projects\node_modules\string-width\index.js not supported.
Instead change the require of C:\projects\node_modules\strip-ansi\index.js in C:\projects\node_modules\string-width\index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (C:\projects\node_modules\string-width\index.js:2:19)
    at Object.<anonymous> (C:\projects\node_modules\cliui\build\index.cjs:291:21)
    at Object.<anonymous> (C:\projects\node_modules\yargs\build\index.cjs:1:60678) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v18.17.1


⚠️  Ups, something went wrong: Error calling: npx wdio config!
error Command failed.
Exit code: 1
Command: C:\Users\qtpmg\AppData\Local\Yarn\bin\create-wdio
Arguments: .
Directory: C:\projects\project3
Output:

info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.



--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------



OUTPUT #2
PS C:\projects\project2> npm run wdio  
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\projects\project2/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\projects\project2\package.json'   
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in: C:\Users\qtpmg\AppData\Local\npm-cache\_logs\2023-11-03T09_48_58_514Z-debug-0.log

--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------


0 verbose cli C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
1 info using npm@9.6.7
2 info using node@v18.17.1
3 timing npm:load:whichnode Completed in 2ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:C:\Users\qtpmg\AppData\Roaming\nvm\v18.17.1\node_modules\npm\npmrc Completed in 1ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:C:\projects\project2\.npmrc Completed in 0ms
10 timing config:load:project Completed in 4ms
11 timing config:load:file:C:\Users\qtpmg\.npmrc Completed in 0ms
12 timing config:load:user Completed in 1ms
13 timing config:load:file:C:\Program Files\nodejs\etc\npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:setEnvs Completed in 1ms
16 timing config:load Completed in 11ms
17 timing npm:load:configload Completed in 11ms
18 timing npm:load:mkdirpcache Completed in 0ms
19 timing npm:load:mkdirplogs Completed in 0ms
20 verbose title npm run wdio
21 verbose argv "run" "wdio"
22 timing npm:load:setTitle Completed in 1ms
23 timing config:load:flatten Completed in 3ms
24 timing npm:load:display Completed in 3ms
25 verbose logfile logs-max:10 dir:C:\Users\qtpmg\AppData\Local\npm-cache\_logs\2023-11-03T09_48_58_514Z-
26 verbose logfile C:\Users\qtpmg\AppData\Local\npm-cache\_logs\2023-11-03T09_48_58_514Z-debug-0.log
27 timing npm:load:logFile Completed in 12ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 29ms
31 timing command:run Completed in 1ms
32 verbose stack Error: ENOENT: no such file or directory, open 'C:\projects\project2\package.json'
33 verbose cwd C:\projects\project2
34 verbose Windows_NT 10.0.22621
35 verbose node v18.17.1
36 verbose npm  v9.6.7
37 error code ENOENT
38 error syscall open
39 error path C:\projects\project2/package.json
40 error errno -4058
41 error enoent ENOENT: no such file or directory, open 'C:\projects\project2\package.json'
42 error enoent This is related to npm not being able to find a file.
42 error enoent
43 verbose exit -4058
44 timing npm Completed in 56ms
45 verbose code -4058
46 error A complete log of this run can be found in: C:\Users\qtpmg\AppData\Local\npm-cache\_logs\2023-11-03T09_48_58_514Z-debug-0.log

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

Metadata

Metadata

Assignees

Labels

Bug 🐛good first picka reasonable task to start getting familiar with the code basehelp wantedIssues that are free to take by anyone interested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions