File tree Expand file tree Collapse file tree 4 files changed +54
-2
lines changed Expand file tree Collapse file tree 4 files changed +54
-2
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ module.exports = (on, config) => {
2020 // `on` is used to hook into various events Cypress emits
2121 // `config` is the resolved Cypress config
2222
23+ // eslint-disable-next-line global-require
24+ require ( "./memoryUsageLogger" ) ( on ) ;
25+
2326 // eslint-disable-next-line global-require
2427 require ( "cypress-timestamps/plugin" ) ( on ) ;
2528} ;
Original file line number Diff line number Diff line change 1+ /**
2+ * @type {Cypress.PluginConfig }
3+ */
4+ // eslint-disable-next-line no-unused-vars
5+ module . exports = ( on , config ) => {
6+ // Add a task to log memory usage to the terminal
7+ on ( "task" , {
8+ logMemoryUsage ( browserMemoryUsage ) {
9+ const formatBytes = ( bytes ) =>
10+ ( bytes / 1024 / 1024 / 1024 ) . toFixed ( 3 ) + " GB" ;
11+
12+ if ( browserMemoryUsage ) {
13+ console . log ( "=== Browser Tab Memory Usage ===" ) ;
14+ console . log ( `Used: ${ formatBytes ( browserMemoryUsage . usedJSHeapSize ) } ` ) ;
15+ console . log (
16+ `Total: ${ formatBytes ( browserMemoryUsage . totalJSHeapSize ) } ` ,
17+ ) ;
18+ console . log (
19+ `Limit: ${ formatBytes ( browserMemoryUsage . jsHeapSizeLimit ) } ` ,
20+ ) ;
21+ }
22+
23+ const cypressMemoryUsage = process . memoryUsage ( ) ;
24+ console . log ( "=== Cypress Memory Usage ===" ) ;
25+ console . log ( `rss: ${ formatBytes ( cypressMemoryUsage . rss ) } ` ) ;
26+ console . log ( `heapTotal: ${ formatBytes ( cypressMemoryUsage . heapTotal ) } ` ) ;
27+ console . log ( `heapUsed: ${ formatBytes ( cypressMemoryUsage . heapUsed ) } ` ) ;
28+ console . log ( `external: ${ formatBytes ( cypressMemoryUsage . external ) } ` ) ;
29+ console . log (
30+ `arrayBuffers: ${ formatBytes ( cypressMemoryUsage . arrayBuffers ) } ` ,
31+ ) ;
32+
33+ return null ;
34+ } ,
35+ } ) ;
36+ } ;
Original file line number Diff line number Diff line change @@ -39,3 +39,15 @@ beforeEach(function () {
3939 }
4040 }
4141} ) ;
42+
43+ afterEach ( ( ) => {
44+ cy . window ( ) . then ( ( win ) => {
45+ const browserMemoryUsage = {
46+ usedJSHeapSize : win . performance ?. memory ?. usedJSHeapSize ,
47+ totalJSHeapSize : win . performance ?. memory ?. totalJSHeapSize ,
48+ jsHeapSizeLimit : win . performance ?. memory ?. jsHeapSizeLimit ,
49+ } ;
50+
51+ cy . task ( "logMemoryUsage" , browserMemoryUsage ) ;
52+ } ) ;
53+ } ) ;
Original file line number Diff line number Diff line change @@ -262,8 +262,9 @@ def test_run_cypress(auth_session):
262262 test_spec_arg = f" --spec '{ specs_str } ' "
263263
264264 print ("Running Cypress tests with command" )
265- node_options = "--max-old-space-size=6000"
266- command = f'NO_COLOR=1 NODE_OPTIONS="{ node_options } " npx cypress run { record_arg } { test_spec_arg } { tag_arg } --config numTestsKeptInMemory=2'
265+ node_options = "--max-old-space-size=500"
266+ electron_args = 'ELECTRON_EXTRA_LAUNCH_ARGS="--js-flags=\' --max-old-space-size=4096 --disable-dev-shm-usage --disable-gpu --no-sandbox"'
267+ command = f'{ electron_args } NO_COLOR=1 NODE_OPTIONS="{ node_options } " npx cypress run { record_arg } { test_spec_arg } { tag_arg } --config numTestsKeptInMemory=2'
267268 print (command )
268269 # Add --headed --spec '**/mutations/mutations.js' (change spec name)
269270 # in case you want to see the browser for debugging
You can’t perform that action at this time.
0 commit comments