From d1f01da5d492da4378e083fb6b6baa7a41a4bd8c Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Fri, 11 Jul 2025 23:19:05 -0500 Subject: [PATCH 1/7] have the lint job use newest caches instead of oldest --- .github/workflows/lint-js-and-ruby.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint-js-and-ruby.yml b/.github/workflows/lint-js-and-ruby.yml index 783c7e2d56..1919b31df0 100644 --- a/.github/workflows/lint-js-and-ruby.yml +++ b/.github/workflows/lint-js-and-ruby.yml @@ -39,7 +39,7 @@ jobs: uses: actions/cache@v4 with: path: vendor/bundle - key: package-app-gem-cache-${{ hashFiles('Gemfile.lock') }}-oldest + key: package-app-gem-cache-${{ hashFiles('Gemfile.lock') }}-newest - name: Install Node modules with Yarn for renderer package run: | yarn install --no-progress --no-emoji --frozen-lockfile @@ -60,7 +60,7 @@ jobs: uses: actions/cache@v4 with: path: spec/dummy/vendor/bundle - key: dummy-app-gem-cache-${{ hashFiles('spec/dummy/Gemfile.lock') }}-oldest + key: dummy-app-gem-cache-${{ hashFiles('spec/dummy/Gemfile.lock') }}-newest - name: Install Ruby Gems for dummy app run: | cd spec/dummy From a852f43a14ff2fbe87d84d6d01e7512f03565ea7 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Sat, 12 Jul 2025 00:02:06 -0500 Subject: [PATCH 2/7] disable all console logs during Jest tests --- node_package/tests/jest.setup.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/node_package/tests/jest.setup.js b/node_package/tests/jest.setup.js index 5b4acefa32..2168cd2e5d 100644 --- a/node_package/tests/jest.setup.js +++ b/node_package/tests/jest.setup.js @@ -62,3 +62,11 @@ if (typeof window !== 'undefined') { global.ReadableStream = ReadableStream; global.ReadableStreamDefaultReader = ReadableStreamDefaultReader; } + +global.console = { + log: jest.fn(), + error: jest.fn(), + warn: jest.fn(), + info: jest.fn(), + debug: jest.fn(), +}; From 40e21f0e28ebda69f5c571bf68cbb094e82da1af Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Sat, 12 Jul 2025 00:11:11 -0500 Subject: [PATCH 3/7] newest cache is still borked --- .github/workflows/lint-js-and-ruby.yml | 4 ++-- node_package/tests/jest.setup.js | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint-js-and-ruby.yml b/.github/workflows/lint-js-and-ruby.yml index 1919b31df0..f90d45c05b 100644 --- a/.github/workflows/lint-js-and-ruby.yml +++ b/.github/workflows/lint-js-and-ruby.yml @@ -39,7 +39,7 @@ jobs: uses: actions/cache@v4 with: path: vendor/bundle - key: package-app-gem-cache-${{ hashFiles('Gemfile.lock') }}-newest + key: package-app-gem-cache-${{ hashFiles('Gemfile.lock') }}-lint - name: Install Node modules with Yarn for renderer package run: | yarn install --no-progress --no-emoji --frozen-lockfile @@ -60,7 +60,7 @@ jobs: uses: actions/cache@v4 with: path: spec/dummy/vendor/bundle - key: dummy-app-gem-cache-${{ hashFiles('spec/dummy/Gemfile.lock') }}-newest + key: dummy-app-gem-cache-${{ hashFiles('spec/dummy/Gemfile.lock') }}-lint - name: Install Ruby Gems for dummy app run: | cd spec/dummy diff --git a/node_package/tests/jest.setup.js b/node_package/tests/jest.setup.js index 2168cd2e5d..d55a673044 100644 --- a/node_package/tests/jest.setup.js +++ b/node_package/tests/jest.setup.js @@ -63,10 +63,12 @@ if (typeof window !== 'undefined') { global.ReadableStreamDefaultReader = ReadableStreamDefaultReader; } +global.console.log("All calls to console have been disabled in jest.setup.js") + global.console = { log: jest.fn(), error: jest.fn(), warn: jest.fn(), info: jest.fn(), debug: jest.fn(), -}; +} From 5c1f9c258ad048032f02e73feda754159b77607c Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Thu, 10 Jul 2025 19:03:09 -0500 Subject: [PATCH 4/7] linting --- node_package/tests/jest.setup.js | 4 ++-- spec/dummy/tests/react-on-rails.import.test.js | 4 +++- spec/dummy/tests/react-on-rails.require.test.js | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/node_package/tests/jest.setup.js b/node_package/tests/jest.setup.js index d55a673044..333efa80c1 100644 --- a/node_package/tests/jest.setup.js +++ b/node_package/tests/jest.setup.js @@ -63,7 +63,7 @@ if (typeof window !== 'undefined') { global.ReadableStreamDefaultReader = ReadableStreamDefaultReader; } -global.console.log("All calls to console have been disabled in jest.setup.js") +global.console.log('All calls to console have been disabled in jest.setup.js'); global.console = { log: jest.fn(), @@ -71,4 +71,4 @@ global.console = { warn: jest.fn(), info: jest.fn(), debug: jest.fn(), -} +}; diff --git a/spec/dummy/tests/react-on-rails.import.test.js b/spec/dummy/tests/react-on-rails.import.test.js index c13ef69b82..e2af3df943 100644 --- a/spec/dummy/tests/react-on-rails.import.test.js +++ b/spec/dummy/tests/react-on-rails.import.test.js @@ -1,5 +1,7 @@ import ReactOnRails from 'react-on-rails'; test('ReactOnRails', () => { - ReactOnRails.register({}); + expect(() => { + ReactOnRails.register({}); + }).not.toThrow(); }); diff --git a/spec/dummy/tests/react-on-rails.require.test.js b/spec/dummy/tests/react-on-rails.require.test.js index acac258e96..7d96d5a996 100644 --- a/spec/dummy/tests/react-on-rails.require.test.js +++ b/spec/dummy/tests/react-on-rails.require.test.js @@ -1,5 +1,7 @@ const ReactOnRails = require('react-on-rails').default; test('ReactOnRails', () => { - ReactOnRails.register({}); + expect(() => { + ReactOnRails.register({}); + }).not.toThrow(); }); From f6e53629ba6291b2e74982f086d1aee4feb5c553 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Sat, 12 Jul 2025 00:23:59 -0500 Subject: [PATCH 5/7] breaking test to check CI output --- node_package/tests/renderFunction.test.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node_package/tests/renderFunction.test.jsx b/node_package/tests/renderFunction.test.jsx index 7372216656..cbb4e95931 100644 --- a/node_package/tests/renderFunction.test.jsx +++ b/node_package/tests/renderFunction.test.jsx @@ -15,7 +15,7 @@ describe('isRenderFunction', () => { }, }); - expect(isRenderFunction(es5Component)).toBe(false); + expect(true).toBe(false); }); it('returns false for a ES6 React class', () => { From 4f9b4ea00d35bbaf32372b4ffc7c8afb17c808b7 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Sat, 12 Jul 2025 00:31:20 -0500 Subject: [PATCH 6/7] jest output looks much better --- node_package/tests/renderFunction.test.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node_package/tests/renderFunction.test.jsx b/node_package/tests/renderFunction.test.jsx index cbb4e95931..7372216656 100644 --- a/node_package/tests/renderFunction.test.jsx +++ b/node_package/tests/renderFunction.test.jsx @@ -15,7 +15,7 @@ describe('isRenderFunction', () => { }, }); - expect(true).toBe(false); + expect(isRenderFunction(es5Component)).toBe(false); }); it('returns false for a ES6 React class', () => { From a089e05f730c3182d7d856cc520664711e2ef1c2 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Sun, 13 Jul 2025 23:00:19 -0500 Subject: [PATCH 7/7] add env var --- node_package/tests/jest.setup.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/node_package/tests/jest.setup.js b/node_package/tests/jest.setup.js index 333efa80c1..2758e3eb80 100644 --- a/node_package/tests/jest.setup.js +++ b/node_package/tests/jest.setup.js @@ -63,12 +63,14 @@ if (typeof window !== 'undefined') { global.ReadableStreamDefaultReader = ReadableStreamDefaultReader; } -global.console.log('All calls to console have been disabled in jest.setup.js'); +if (!['yes', 'true', 'y', 't'].includes(process.env.ENABLE_JEST_CONSOLE || ''.toLowerCase())) { + global.console.log('All calls to console have been disabled in jest.setup.js'); -global.console = { - log: jest.fn(), - error: jest.fn(), - warn: jest.fn(), - info: jest.fn(), - debug: jest.fn(), -}; + global.console = { + log: jest.fn(), + error: jest.fn(), + warn: jest.fn(), + info: jest.fn(), + debug: jest.fn(), + }; +}