Bug 40809 - JS warning should make Cypress tests fail
Summary: JS warning should make Cypress tests fail
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement
Assignee: Jonathan Druart
QA Contact: Matt Blenkinsop
URL:
Keywords:
Depends on:
Blocks: 38201
  Show dependency treegraph
 
Reported: 2025-09-15 12:22 UTC by Jonathan Druart
Modified: 2025-09-26 16:41 UTC (History)
2 users (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Crowdfunding goal: 0
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
25.11.00
Circulation function:


Attachments
Bug 40809: Fail Cypress tests on JS warnings (1.23 KB, patch)
2025-09-15 12:25 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 40809: Fail on DataTables 'warnings' (1.22 KB, patch)
2025-09-26 05:03 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 40809: Fail Cypress tests on JS warnings (1.29 KB, patch)
2025-09-26 10:37 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 40809: Fail on DataTables 'warnings' (1.29 KB, patch)
2025-09-26 10:38 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 40809: Display the whole error (1.74 KB, patch)
2025-09-26 10:38 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 40809: Display the whole error (1.80 KB, patch)
2025-09-26 10:45 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 40809: Also logs args in the console (998 bytes, patch)
2025-09-26 14:58 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2025-09-15 12:22:57 UTC

    
Comment 1 Jonathan Druart 2025-09-15 12:25:42 UTC
Created attachment 186401 [details] [review]
Bug 40809: Fail Cypress tests on JS warnings

Currently JS warnings during Cypress tests are ignored.
This change intercepts console warnings in the browser and if any occurs
the test failed

This helps catch potential issues and ensures that warnings are not
silently ignored during test runs.
Comment 2 Jonathan Druart 2025-09-15 12:50:22 UTC
Test plan:
All Cypress tests should still pass.

QA will take care of adding a JS warning and confirm that the test fails.
Comment 3 Jonathan Druart 2025-09-26 05:03:19 UTC
Created attachment 186951 [details] [review]
Bug 40809: Fail on DataTables 'warnings'

They are not in the warn buffer but log
DataTables warning: table id=DataTables_Table_0 - Requested unknown parameter 'status' for row 0, column 4. For more information about this error, please see https://datatables.net/tn/4
Comment 4 Matt Blenkinsop 2025-09-26 10:37:59 UTC
Created attachment 186966 [details] [review]
Bug 40809: Fail Cypress tests on JS warnings

Currently JS warnings during Cypress tests are ignored.
This change intercepts console warnings in the browser and if any occurs
the test failed

This helps catch potential issues and ensures that warnings are not
silently ignored during test runs.

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Comment 5 Matt Blenkinsop 2025-09-26 10:38:01 UTC
Created attachment 186967 [details] [review]
Bug 40809: Fail on DataTables 'warnings'

They are not in the warn buffer but log
DataTables warning: table id=DataTables_Table_0 - Requested unknown parameter 'status' for row 0, column 4. For more information about this error, please see https://datatables.net/tn/4

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Comment 6 Jonathan Druart 2025-09-26 10:38:24 UTC
Created attachment 186968 [details] [review]
Bug 40809: Display the whole error

Not only the first line
Comment 7 Matt Blenkinsop 2025-09-26 10:45:23 UTC
Created attachment 186969 [details] [review]
Bug 40809: Display the whole error

Not only the first line

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Comment 8 Jonathan Druart 2025-09-26 14:58:31 UTC
Created attachment 186977 [details] [review]
Bug 40809: Also logs args in the console

For an unknown reason there are useful data that are displayed when
using console.log that we don't see when throwing the Error
This was the purpose of the previous patch (to have everything in
Error) but it didn't work. However we can keep it.
Comment 9 Lucas Gass (lukeg) 2025-09-26 16:34:04 UTC
I'm ignoring this QA failure:

Result:
[FAIL] t/cypress/support/e2e.js
   FAIL	  forbidden_patterns
		forbidden pattern: console.log (line 41)
		forbidden pattern: console.log (line 45)
Comment 10 Lucas Gass (lukeg) 2025-09-26 16:41:06 UTC
Nice work everyone!

Pushed to main for 25.11