Inconsistent assert behavior for text
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript, node.js
- 領域
- testing-qa
調査の方向性
まず、examples/returns.html と examples/bootstrap.html を使って提供されたシナリオを実行し、次に I.see、I.waitForText、I.grabTextFrom を #app および #app.at(1) と比較します。各 assertion がどこからテキストを取得し、どのように正規化するかを追跡します。これらのメソッド、セレクター、空白、スタイリングのケース全体で、期待されるテキストの動作が定義され、一貫していれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Hello!
While experimenting with codecept I noticed inconsistent behaviors between the testing methods.
Here are two tests:
- The first contains spans that have numbers in them. The asserts are generally consistent (they add spaces to each span) except grabTextFrom, which adds \n.
- The second is much more problematic. In this one, the HTML also contains spans, but with bootstrap styles on the spans. We can see that:
- I.see adds spaces
- I.waitForText does not
- nor does I.grabTextFrom
- BUT when we add .at(1) to the locator, it changes the behavior of waitForText().
The way the text is asserted changes depending on:
- the CSS of the page
- the assertion method used
- the selector
- the whitespaces in the HTML
import { writeFileSync } from "node:fs";
import { resolve } from "node:path";
Feature("Spans");
Scenario("text line returns", async ({ I }) => {
const file = `${resolve(process.cwd(), "examples", "returns.html")}`;
writeFileSync(file, `
<div id="app">
<span>1</span>
<span>2</span>
<span>3</span>
</div>
`);
I.amOnPage(`file://${file}`);
const appLocator = locate("#app");
I.see("1 2 3", appLocator);
I.waitForText("1 2 3", 1, appLocator);
const text = await I.grabTextFrom(appLocator);
I.expect(text).toEqual("\n 1\n 2\n 3\n ");
I.see("1 2 3", appLocator.at(1));
I.waitForText("1 2 3", 1, appLocator.at(1));
const text2 = await I.grabTextFrom(appLocator.at(1));
I.expect(text2).toEqual("\n 1\n 2\n 3\n ");
});
Scenario("test boostrap styles", async ({ I }) => {
const file = `${resolve(process.cwd(), "examples", "bootstrap.html")}`;
writeFileSync(file, `
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<div class="d-flex align-items-baseline lh-1 monospace-numbers" id="app"><span class="text-nowrap fs-21 lh-1">0</span><span class="text-nowrap fs-21 lh-1">.</span><span class="text-nowrap fs-21 lh-1">8</span><span class="text-nowrap fs-21 lh-1">8</span><span class="text-nowrap fs-48 lh-1">6</span><span class="text-nowrap fs-48 lh-1">7</span><span class="text-nowrap fs-18 lh-1 align-self-start mt-1">8</span></div>
`);
I.amOnPage(`file://${file}`);
const appLocator = locate("#app");
I.see("0 . 8 8 6 7 8", appLocator);
I.waitForText("0.88678", 1, appLocator);
const text = await I.grabTextFrom(appLocator);
I.expect(text).toEqual("0.88678");
I.see("0 . 8 8 6 7 8", appLocator.at(1));
// IDK what it expects... it just does not work the same with .at(1)!!!!
// I.waitForText("0.88678", 1, appLocator.at(1));
const text2 = await I.grabTextFrom(appLocator.at(1));
I.expect(text2).toEqual("0.88678");
});
- 主要言語
- JavaScript
- スター
- 4.2k
- フォーク
- 756
- 平均マージ
- 2日 9時間
- マージ済み PR(30日)
- 16
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
codeceptjs/CodeceptJS のほかの issue
-
stale
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
codeceptjs/CodeceptJS#5420 · コメント 1 件 ·
-
stale
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
codeceptjs/CodeceptJS#5358 · コメント 1 件 ·
-
stale
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
codeceptjs/CodeceptJS#4958 · コメント 10 件 · リアクション 2 件 ·
-
stale
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
codeceptjs/CodeceptJS#4778 · コメント 3 件 ·
-
stale
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
codeceptjs/CodeceptJS#5618 · コメント 1 件 ·
codeceptjs/CodeceptJS の issue をすべて見る
似ている issue
-
ai-observability bug team/ai-observability
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
AllTheMods/ATM-10-L#19 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
SignalK/n2k-signalk#345 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
JuliaPluto/PlutoPlotly.jl#72 ·