@@ -68,6 +68,26 @@ if (!process.env.RUBY_NPM_PACKAGE_ROOT) {
6868 expect ( await resolve ( ) ) . toBe ( false ) ;
6969 } ) ;
7070
71+ test ( "JS::RequireRemote#load throws error when gem is not found" , async ( {
72+ page,
73+ } ) => {
74+ // Opens the URL that will be used as the basis for determining the relative URL.
75+ await page . goto (
76+ "https://cdn.jsdelivr.net/npm/ruby-head-wasm-wasi@latest/dist/" ,
77+ ) ;
78+ await page . setContent ( `
79+ <script src="https://cdn.jsdelivr.net/npm/ruby-head-wasm-wasi@latest/dist/browser.script.iife.js">
80+ </script>
81+ <script type="text/ruby" data-eval="async">
82+ require 'js/require_remote'
83+ JS::RequireRemote.instance.load 'foo'
84+ </script>
85+ ` ) ;
86+
87+ const error = await page . waitForEvent ( "pageerror" ) ;
88+ expect ( error . message ) . toMatch ( / c a n n o t l o a d s u c h u r l - - .+ \/ f o o .r b / ) ;
89+ } ) ;
90+
7191 // TODO: This test fails.
7292 // In the integration test, response#url returns the URL before the redirect.
7393 // I do not know the cause. Under investigation.
@@ -94,25 +114,5 @@ if (!process.env.RUBY_NPM_PACKAGE_ROOT) {
94114
95115 expect ( await resolve ( ) ) . toBe ( false ) ;
96116 } ) ;
97-
98- test ( "JS::RequireRemote#load throws error when gem is not found" , async ( {
99- page,
100- } ) => {
101- // Opens the URL that will be used as the basis for determining the relative URL.
102- await page . goto (
103- "https://cdn.jsdelivr.net/npm/ruby-head-wasm-wasi@latest/dist/" ,
104- ) ;
105- await page . setContent ( `
106- <script src="https://cdn.jsdelivr.net/npm/ruby-head-wasm-wasi@latest/dist/browser.script.iife.js">
107- </script>
108- <script type="text/ruby" data-eval="async">
109- require 'js/require_remote'
110- JS::RequireRemote.instance.load 'foo'
111- </script>
112- ` ) ;
113-
114- const error = await page . waitForEvent ( "pageerror" ) ;
115- expect ( error . message ) . toMatch ( / c a n n o t l o a d s u c h u r l - - .+ \/ f o o .r b / ) ;
116- } ) ;
117117 } ) ;
118118}
0 commit comments