test('has title',async({ page })=>{await page.goto('http://exapmle.com/redirect');// Expect a title "to contain" a substring.await expect(page).toHaveTitle(/Playwright/);});
開くURLを http://exapmle.com/redirect に変更します。
テストを実行してみましょう。
npx playwright test --project=chromium --uiでテストを起動します。
initializer in this case is an npm package named create-, which will be installed by npm-exec, and then have its main bin executed -- presumably creating or updating package.json and running any other initialization-related operations.
4 failed
[firefox] › example.spec.ts:3:5 › has title ────────────────────────────────────────────────────
[firefox] › example.spec.ts:10:5 › get started link ────────────────────────────────────────────
[webkit] › example.spec.ts:3:5 › has title ─────────────────────────────────────────────────────
[webkit] › example.spec.ts:10:5 › get started link ─────────────────────────────────────────────
2 passed (2.0s)
<html><scriptsrc="browser.script.iife.js"></script><scripttype="text/ruby"> require 'js/require_remote' module Kernel alias original_require_relative require_relative # The require_relative may be used in the embedded Gem. # First try to load from the built-in filesystem, and if that fails, # load from the URL. def require_relative(path)
caller_path = caller_locations(1, 1).first.absolute_path || '' dir = File.dirname(caller_path)
file = File.absolute_path(path, dir)
original_require_relative(file)
rescue LoadError JS::RequireRemote.instance.load(path)
end end</script><scripttype="text/ruby"data-eval="async"> p require_relative 'redirect' p require_relative 'app'</script></html>
ただし次のようにリダイレクトを交えたrequire_relativeを実行します。
p require_relative'redirect'
p require_relative'app'
sequenceDiagram
participant Client
participant Server
Client->>Client: require_relative "a"
Client->>Client: fetch('a.rb')
Client->>Server: GET request './a.rb'
Server->>Client: 302 Response with './b.rb'
Client->>Server: GET request for './b.rb'
Server->>Client: Ruby script transfer
Client->>Client: Kernel.eval Ruby script