Skip to content

fix: prevent Opal from being loaded twice in tests#2

Merged
takaokouji merged 5 commits into
developfrom
feature/phase3-migrate-scratch-gui
Jan 19, 2026
Merged

fix: prevent Opal from being loaded twice in tests#2
takaokouji merged 5 commits into
developfrom
feature/phase3-migrate-scratch-gui

Conversation

@takaokouji
Copy link
Copy Markdown

Description

This PR addresses an issue where Jest test outputs were being flooded with a massive JavaScript source dump from the minified Opal library.

The root cause was that Opal was being initialized multiple times (once in a Jest setup file and again in ruby-parser.js), which triggered Opal's internal "already loaded" warning. Jest then attempted to display the context of this warning, resulting in the dump.

Changes

  • Modified src/lib/ruby-parser.js to only require('opal') and require('opal-parser') if Opal is not already defined in the global or window scope.
  • Updated src/lib/ruby-to-blocks-converter/index.js to remove redundant require calls, favoring the initialization in ruby-parser.js.
  • Added an explicit check in index.js to ensure Opal is initialized before proceeding.

Verification

  • Ran the affected test: npm exec jest test/unit/lib/ruby-to-blocks-converter/ruby.test.js
  • Confirmed that tests pass and the large source dump is no longer present.
  • Ran ESLint on modified files.

takaokouji and others added 4 commits January 19, 2026 11:37
Added explicit Opal.load calls for 'opal-parser', 'parser', and 'parser/ruby31'
to ensure Opal.Parser.Ruby31 is available. This fixes the issue where
RubyParser was undefined during unit tests.

🤖 Generated with [Gemini Code](https://gemini.google.com/code)

Co-Authored-By: Gemini <noreply@google.com>
Migrated components, containers, reducers, and libraries for:
- Opal integration and Ruby-to-Blocks converter
- Custom modals (Mesh, Koshien, Block Display, etc.)
- Ruby tab and snippets
- Build scripts and post-processing

🤖 Generated with [Gemini Code](https://gemini.google.com/code)

Co-Authored-By: Gemini <noreply@google.com>
- Modified ruby-parser.js to only require Opal if not already defined.
- Added safer check for both global.Opal and window.Opal.
- This eliminates the large JavaScript dump in Jest outputs.
- Updated ruby-to-blocks-converter/index.js to remove redundant require calls.
- Fix 'Unexpected this' in ruby-to-blocks-converter
- Fix 'intlShape not found' in url-loader-hoc.jsx
- Remove unused 'opalParserConfig' in webpack.config.js
- Prefix unused variables/props with '_'
- Update ESLint config to ignore '_' prefixed arguments

🤖 Generated with [Gemini Code](https://gemini.google.com/code)

Co-Authored-By: Gemini <noreply@google.com>
@takaokouji takaokouji force-pushed the feature/phase3-migrate-scratch-gui branch from 34a53b2 to 9bb0982 Compare January 19, 2026 08:10
- Migrated integration and unit tests from smalruby3-gui
- Migrated extension-filter reducer and CSS
- Migrated ADRs and Google Drive setup docs
- Updated test paths for themes and menu XPaths

🤖 Generated with [Gemini Code](https://gemini.google.com/code)

Co-Authored-By: Gemini <noreply@google.com>
@takaokouji takaokouji merged commit 7b5da4b into develop Jan 19, 2026
@takaokouji takaokouji deleted the feature/phase3-migrate-scratch-gui branch January 19, 2026 08:44
takaokouji pushed a commit that referenced this pull request Mar 8, 2026
takaokouji added a commit that referenced this pull request Apr 12, 2026
- Add next-steps guidance after student joins classroom (#1)
- Add submit hint for students who haven't submitted yet (#2)
- Add STAGE !== 'prod' failsafe for DEV_BYPASS_TOKEN (#3)
- Add fullscreen tooltip to join code expand button (#4)
- Improve member grid prompt to clarify clickable seats (#5)
- Remove window._classroomIdToken debug variable (#8)

Closes #495

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
takaokouji added a commit that referenced this pull request Apr 18, 2026
Map "Jimmy" * 5 to stringMethod block with METHOD=*.
Generator emits infix notation (receiver * arg) instead of
dot notation. finishTargets regex handles * operator inlining.

Handle numeric arguments with _addNumberInput instead of
_addTextInput to avoid type mismatch.

Refs #524 (Phase 1 #2)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant