-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Proposal] Remove webdriverio deprecation notice the ugly way
Our tests run with the test framework `vitest`, which is for now using the `webdriverio` dependency to run it on real browser environments. However, it seems that `vitest` is using a deprecated API for each tests resulting in `webdriverio` outputing a warning log after each of them. Considering that we have thousands of tests, it makes the outputs of integration tests unreadable, output which is particularly important when running test scripts. This could be considered as a `vitest` issue, and they have been made aware of it through their #6804 issue (I'm not linking it in any way here as GitHub as the annoying tendency to spam messages to the original issue when linked that way, but it's the one named "`switchToFrame` deprecated in WebdriverIO v9"). But in the meantime it has been several month and it's hard to write and run integration tests with that mess. So here I'm proposing to just uglily patch console functions in `vitest`'s "globalSetup" script.
- Loading branch information
1 parent
3dee043
commit 303a16f
Showing
3 changed files
with
45 additions
and
8 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
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import createContentServer from "./contents/server.mjs"; | ||
|
||
const realConsoleWarn = console.warn; | ||
let contentServer; | ||
|
||
/** | ||
* Peform actions we want to setup before tests. | ||
*/ | ||
export function setup() { | ||
removeAnnoyingDeprecationNotice(); | ||
contentServer = createContentServer(); | ||
} | ||
|
||
/** | ||
* Peform actions to clean-up after tests. | ||
*/ | ||
export function teardown() { | ||
contentServer?.close(); | ||
} | ||
|
||
/** | ||
* Webdriverio just spams a deprecation notice with the current version of | ||
* vitest (one per test, though as we have thousands of tests, it just fills the | ||
* output into something unreadable). | ||
* | ||
* This is so annoying that I just chose to mute it by monkey-patching the | ||
* console function here. | ||
* | ||
* This should hopefully be very temporary. | ||
*/ | ||
function removeAnnoyingDeprecationNotice() { | ||
console.warn = function (...args) { | ||
if ( | ||
typeof args[0] === "string" && | ||
args[0].startsWith( | ||
'⚠️ [WEBDRIVERIO DEPRECATION NOTICE] The "switchToFrame" command is deprecated and we encourage everyone to use `switchFrame` instead for switching into frames.', | ||
) | ||
) { | ||
return; | ||
} | ||
return realConsoleWarn.apply(console, args); | ||
}; | ||
} |
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