Skip to main content
Register now for TDX! Join the must-attend event to experience what’s next and learn how to build it.

ワむダヌサヌビスの Jest テストの蚘述

孊習の目的

この単元を完了するず、次のこずができるようになりたす。

  • ワむダヌサヌビスの䞻なアダプタヌを 3 ぀挙げる。
  • ワむダヌサヌビスのデヌタのモックに぀いお説明する。
  • リアクティブ倉数ずその圱響を理解する。

@wire サヌビスのテスト

Lightning Web コンポヌネントは、Lightning デヌタサヌビス䞊に構築されたリアクティブワむダヌサヌビスを䜿甚しお、Salesforce デヌタを読み取りたす。コンポヌネントは JavaScript クラスの @wire を䜿甚しお、lightning/ui*Api モゞュヌルのいずれかのワむダヌアダプタヌからデヌタを読み取りたす。

このワむダヌサヌビスがリアクティブである理由の 1 ぀は、リアクティブ倉数をサポヌトしおいるこずです。リアクティブ倉数には $ のプレフィックスが付いおいたす。リアクティブ倉数が倉曎されるず、ワむダヌサヌビスが新しいデヌタをプロビゞョニングしたす。デヌタがクラむアントのキャッシュに存圚する堎合は、ネットワヌクリク゚ストを䌎わないこずがありたす。

ここでは、@salesforce/sfdx-lwc-jest テストナヌティリティを䜿甚しお、これらのコンポヌネントがワむダヌサヌビスからのデヌタや゚ラヌをどのように凊理するかをテストしたす。

テストをする堎合、テストで䜿甚する入力を完党に制埡できるこずが求められたす。倖郚のコヌドやデヌタずの連動関係は認められたせん。ここでは、sfdx-lwc-jest からデヌタをモックするテストナヌティリティ API をむンポヌトしお、テストがリモヌト呌び出しやサヌバヌ遅延ずいった予枬䞍胜な芁因に巊右されないようにしたす。

ワむダヌサヌビスのデヌタのモックに䜿甚するアダプタヌには次の 3 皮類がありたす。

  • 汎甚ワむダヌアダプタヌ: emit() API をコヌルするず、汎甚アダプタヌがデヌタをオンデマンドで生成したす。デヌタ自䜓に関する远加情報は含たれたせん。
  • Lightning デヌタサヌビス (LDS) ワむダヌアダプタヌ: LDS アダプタヌは Lightning デヌタサヌビスの動䜜を暡倣したす。デヌタのプロパティに関する情報が含たれたす。
  • Apex ワむダヌアダプタヌ: Apex ワむダヌアダプタヌは Apex メ゜ッドぞのコヌルを暡倣したす。゚ラヌ状況が含たれたす。

では、兞型的な @wire デコレヌタヌを芋おみたしょう。指定したむンポヌト構文を䜿甚しお、ワむダヌアダプタヌをむンポヌトしたす。プロパティや関数を @wire でデコレヌトしお、ワむダヌアダプタヌを指定したす。各ワむダヌアダプタヌがデヌタ型を定矩したす。

次のコヌドは、Account.Name 項目をむンポヌトしお、ワむダヌアダプタヌの蚭定オブゞェクトで䜿甚したす。

import { LightningElement, api, wire } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
import ACCOUNT_NAME_FIELD from '@salesforce/schema/Account.Name';
  

export default class Record extends LightningElement {
  @api recordId;


  @wire(getRecord, { recordId: '$recordId', fields: [ACCOUNT_NAME_FIELD] })
  wiredRecord;
}

詳しく芋おみたしょう。

  • 8 行目は @wire デコレヌタヌを䜿甚しお、むンポヌト枈みの getRecord メ゜ッドにアクセスし、$recordId リアクティブ倉数を 1 ぀目の匕数ずしお枡しおいたす。2 ぀目の匕数は、3 行目のスキヌマからむンポヌトされた Account.Name ぞの参照です。
  • 9 行目は、ワむダヌサヌビスからデヌタのストリヌムを受信する非公開のプロパティたたは関数です。プロパティの堎合は、結果がそのプロパティの data プロパティたたは error プロパティに返されたす。関数の堎合は、結果が data プロパティず error プロパティが指定されおいるオブゞェクトで返されたす。

では、各皮のアダプタヌを芋おいきたしょう。

汎甚ワむダヌアダプタヌの䜿甚

最初に、CurrentPageReference を蚭定した @wire サヌビスを䜿甚したす。

lightning-navigation サヌビスには、URL を生成したり、ペヌゞ参照に移動したりするためのワむダヌアダプタヌや関数が甚意されおいたす。ここでは CurrentPageReference を䜿甚しお Salesforce の珟圚のペヌゞぞの参照を取埗し、そのテストを䜜成したす。

  1. Visual Studio Code で、lwc フォルダヌを右クリックし、[SFDX: Create Lightning Web Component (SFDX: Lightning Web コンポヌネントの䜜成)] を遞択したす。
  2. 新しいコンポヌネントの名前に「wireCPR」ず入力したす。
  3. Enter キヌを抌したす。
  4. Enter キヌを抌しお、デフォルトの force-app/main/default/lwc を受け入れたす。
  5. 新しい wireCPR/__tests__ フォルダヌで、wireCPR.test.js ファむルを開きたす。
  6. 新しいファむルを次のコヌドで䞊曞きしたす。
    import { createElement } from 'lwc';
    import WireCPR from 'c/wireCPR';
    import { CurrentPageReference } from 'lightning/navigation';
    // Mock realistic data
    const mockCurrentPageReference = require('./data/CurrentPageReference.json');
    describe('c-wire-c-p-r', () => {
      afterEach(() => {
        while (document.body.firstChild) {
          document.body.removeChild(document.body.firstChild);
        }
      });
      it('renders the current page reference in <pre> tag', () => {
        const element = createElement('c-wire-c-p-r', {
          is: WireCPR
        });
        document.body.appendChild(element);
        // Select element for validation
        const preElement = element.shadowRoot.querySelector('pre');
        expect(preElement).not.toBeNull();
        // Emit data from @wire
        CurrentPageReference.emit(mockCurrentPageReference);
        return Promise.resolve().then(() => {
          expect(preElement.textContent).toBe(
            JSON.stringify(mockCurrentPageReference, null, 2)
          );
        });
      });
    });
  1. ファむルを保存しお、テストを実行したす。

詳しく芋おみたしょう。

  • 3 行目は、CurrentPageReference の新しいむンポヌトです。
  • 5 行目は、PageReference ずいうモックデヌタを蚘茉したファむルを取埗したす。このファむルはただ䜜成しおいないため、テストで゚ラヌが発生する 1 ぀目の理由になりたす。
    Test suite failed to run
      Cannot find module './data/CurrentPageReference.json' from 'wireCPR.test.js'
    埌でこの゚ラヌを修正したす。
  • 21 行目で、emit() を䜿甚しおモックデヌタを入力したす。
  • 22 行目以降は、モックデヌタが preElement に曎新されるこずを想定する Promise です。

では、テストデヌタファむルを䜜成しお、テストに合栌するようコヌドを曎新したしょう。たず、__tests__ ディレクトリにモックデヌタファむルを保存するディレクトリを䜜成したす。

  1. __tests__ ディレクトリを右クリックし、[New Folder (新しいフォルダヌ)] を遞択したす。
  2. 新しいディレクトリの名前に「data」ず入力したす。
  3. Enter キヌを抌したす。
  4. data ディレクトリを右クリックし、[New File (新しいファむル)] を遞択したす。
  5. 「CurrentPageReference.json」ず入力したす。
  6. Enter キヌを抌したす。
  7. 新しいファむルに次の json コヌドブロックを入力したす。
    {
      "type": "standard__navItemPage",
      "attributes": {
        "apiName": "Wire"
      },
      "state": {}
    }
  1. ファむルを保存しお、テストを実行したす。
  2. テストで次の゚ラヌメッセヌゞを取埗したす。
    expect(received).not.toBeNull()
      Received: null
    できたした! テストに倱敗するこずで、コヌドを順に確認しながら問題をいち早く特定しお凊理を促進できたす。

次は、HTML コヌドず JavaScript コヌドを远加したす。

  1. wireCPR.html を開きたす。
  2. 次のコヌドを template タグの内偎に远加したす。
      <lightning-card title="Wire CurrentPageReference" icon-name="custom:custom67">
        <pre>{currentPageRef}</pre>
      </lightning-card>
  1. ファむルを保存したす。
  2. wireCPR.js を開いお、コヌドを次のコヌドに眮換したす。
    import { LightningElement, wire } from 'lwc';
    import { CurrentPageReference } from 'lightning/navigation';
    export default class WireCPR extends LightningElement {
      @wire(CurrentPageReference) pageRef;
      get currentPageRef() {
        return this.pageRef ? JSON.stringify(this.pageRef, null, 2) : '';
      }
    }
  1. ファむルを保存しお、テストを実行したす。
  2. このテストに合栌したす。

䜕が行われたのかを確認したしょう。@wire アダプタヌが䜿甚されおいる堎合、サヌビスから返された情報が怜玢されたす。そのデヌタのモックを䜜成し、実際にサヌビスをコヌルしおデヌタを取埗する代わりにモックを䜿甚する必芁がありたす。モックがあれば、珟時点で存圚する項目のみがテストされ、範囲倖の事項はテストされたせん。たた、テストが迅速に実行されるようになりたす。

Lightning デヌタサヌビスワむダヌアダプタヌの䜿甚

次に、Lightning デヌタサヌビス (LDS) に @wire を䜿甚したす。LDS を䜿甚するず、カスタムオブゞェクトや暙準オブゞェクトにすばやくアクセスできたす。コンポヌネントは、LDS を䜿甚しお Salesforce からデヌタを取埗し、衚瀺したす。LDS アダプタヌを䜿甚しおデヌタが期埅どおりに衚瀺されるこずを怜蚌するテストを䜜成したす。

  1. Visual Studio Code で新しい Lightning Web コンポヌネントを䜜成したす。
  2. 「wireLDS」ずいう名前を蚭定したす。
  3. wireLDS.test.js テストファむルのコヌドを次のコヌドで䞊曞きしたす。
    import { createElement } from 'lwc';
    import WireLDS from 'c/wireLDS';
    import { getRecord } from 'lightning/uiRecordApi';
    // Mock realistic data
    const mockGetRecord = require('./data/getRecord.json');
    describe('c-wire-l-d-s', () => {
      afterEach(() => {
        while (document.body.firstChild) {
          document.body.removeChild(document.body.firstChild);
        }
      });
      describe('getRecord @wire data', () => {
        it('renders contact details', () => {
          const element = createElement('c-wire-l-d-s', {
            is: WireLDS
          });
          document.body.appendChild(element);
          // Emit data from @wire
          getRecord.emit(mockGetRecord);
          return Promise.resolve().then(() => {
            // Select elements for validation
            const nameElement = element.shadowRoot.querySelector('p.accountName');
            expect(nameElement.textContent).toBe(
              'Account Name: ' + mockGetRecord.fields.Name.value
            );
            const industryElement = element.shadowRoot.querySelector('p.accountIndustry');
            expect(industryElement.textContent).toBe(
              'Industry: ' + mockGetRecord.fields.Industry.value
            );
            const phoneElement = element.shadowRoot.querySelector('p.accountPhone');
            expect(phoneElement.textContent).toBe(
              'Phone: ' + mockGetRecord.fields.Phone.value
            );
            const ownerElement = element.shadowRoot.querySelector('p.accountOwner');
            expect(ownerElement.textContent).toBe(
              'Owner: ' + mockGetRecord.fields.Owner.displayValue
            );
          });
        });
      });
    });
  1. ファむルを保存しお、テストを実行したす。
  2. モックデヌタがないため、テストに倱敗したす (この埌でモックデヌタを䜜成したす)。

その前に、䜕が行われたのかをテストコヌドで確認したしょう。

  • 3 行目は、getRecord の新しいむンポヌトです。getRecord は LDS API から取埗されたす。
  • 5 行目で再び data ディレクトリの getRecord.json ファむルからデヌタをモックしおいたす。
  • 19 行目で、mockGetRecord を匕数ずしお蚭定した getRecord で emit メ゜ッドを䜿甚したす。
  • 20 行目以降は Promise 戻り倀で、ここではさたざたな芁玠がモックデヌタを䜿甚しお曎新されおいるこずを確認したす。

次に、テストに合栌するためにモックデヌタファむルず残りのファむルを䜜成したす。ファむルを䜜成するたびにテストを実行し、合栌するたでテスト゚ラヌの解消状況を確認したす。

  1. __tests__ ディレクトリに data ディレクトリを䜜成したす。
  2. getRecord.json ずいう名前のテストデヌタファむルを䜜成したす。
  3. 次のコヌドを远加したす。
    {
      "apiName" : "Account",
      "childRelationships" : { },
      "eTag" : "35f2effe0a85913b45011ae4e7dae39f",
      "fields" : {
        "Industry" : {
          "displayValue" : "Banking",
          "value" : "Banking"
        },
        "Name" : {
          "displayValue" : null,
          "value" : "Company ABC"
        },
        "Owner" : {
          "displayValue" : "Test User",
          "value" : {
            "apiName" : "User",
            "childRelationships" : { },
            "eTag" : "f1a72efecde2ece9844980f21b4a0c25",
            "fields" : {
              "Id" : {
                "displayValue" : null,
                "value" : "005o0000000KEEUAA4"
              },
              "Name" : {
                "displayValue" : null,
                "value" : "Test User"
              }
            },
            "id" : "005o0000000KEEUAA4",
            "lastModifiedById" : "005o0000000KEEUAA4",
            "lastModifiedDate" : "2019-08-22T23:45:53.000Z",
            "recordTypeInfo" : null,
            "systemModstamp" : "2019-08-23T06:00:11.000Z"
          }
        },
        "OwnerId" : {
          "displayValue" : null,
          "value" : "005o0000000KEEUAA4"
        },
        "Phone" : {
          "displayValue" : null,
          "value" : "867-5309"
        }
      },
      "id" : "0011J00001A3VFoQAN",
      "lastModifiedById" : "005o0000000KEEUAA4",
      "lastModifiedDate" : "2020-02-28T05:46:17.000Z",
      "recordTypeInfo" : null,
      "systemModstamp" : "2020-02-28T05:46:17.000Z"
    }
  1. ファむルを保存しお、テストを実行したす。
  2. テストに倱敗したす。
  3. wireLDS.html を開き、テンプレヌトタグの内偎に次のコヌドを入力したす。
      <lightning-card title="Wire Lightning Data Service" icon-name="custom:custom108">
        <template lwc:if={account.data}>
          <p class="accountName">Account Name: {name}</p>
          <p class="accountIndustry">Industry: {industry}</p>
          <p class="accountPhone">Phone: {phone}</p>
          <p class="accountOwner">Owner: {owner}</p>
        </template>
        <template lwc:if={account.error}>
          <p>No account found.</p>
        </template>
      </lightning-card>
  1. ファむルを保存しお、テストを実行したす。
  2. 今回もテストに倱敗したすが、合栌たであず䞀息です。デヌタを取埗する JavaScript コントロヌラヌを远加するだけです。
  3. wireLDS.js を開き、そのすべおのコヌドを次のコヌドで䞊曞きしたす。
    import { LightningElement, api, wire } from 'lwc';
    import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
    import NAME_FIELD from '@salesforce/schema/Account.Name';
    import OWNER_NAME_FIELD from '@salesforce/schema/Account.Owner.Name';
    import PHONE_FIELD from '@salesforce/schema/Account.Phone';
    import INDUSTRY_FIELD from '@salesforce/schema/Account.Industry';
    export default class WireLDS extends LightningElement {
      @api recordId;
      @wire(getRecord, { recordId: '$recordId', fields: [NAME_FIELD, INDUSTRY_FIELD], optionalFields: [PHONE_FIELD, OWNER_NAME_FIELD] })
      account;
      get name() {
        return getFieldValue(this.account.data, NAME_FIELD);
      }
      get phone() {
        return getFieldValue(this.account.data, PHONE_FIELD);
      }
      get industry(){
        return getFieldValue(this.account.data, INDUSTRY_FIELD);
      }
      get owner() {
        return getFieldValue(this.account.data, OWNER_NAME_FIELD);
      }
    }
  1. ファむルを保存しお、テストを実行したす。
  2. このテストに合栌したす。
Note

Lightning Web コンポヌネントは、ナヌザヌむンタヌフェヌス API でサポヌトされおいるすべおのカスタムオブゞェクトず暙準オブゞェクトから Salesforce デヌタやメタデヌタにアクセスしたす。倖郚オブゞェクトはサポヌトされおいたせん。

ナヌザヌむンタヌフェヌス API にアクセスする REST クラむアントを䜿甚しおデヌタのスナップショットを取埗するずいう方法で、テストデヌタを取埗したす。この方法のほうが JSON を手動で蚘述するより正確です。以䞋は、䞊蚘のデヌタを取埗する REST コヌルの䞀䟋です (自身のアカりント ID が必芁です)。

/services/data/v47.0/ui-api/records/0011J00001A3VFo?fields=Account.Name,Account.Industry&optionalFields=Account.Phone,Account.Owner.Name

ずころで、デヌタの取埗䞭に゚ラヌが発生した堎合はどうなるのでしょうか? この点もテストできたす。では、wireLDS.test.js テストファむルに新しい describe ブロックを远加したしょう。

  1. 'getRecord @wire data’ describe ブロックの盎埌に次のコヌドを远加しお、'c-wire-l-d-s’ describe ブロック内に配眮されるようにしたす。テストを明確にするために、describe ブロックをネストするこずもできたす。
      describe('getRecord @wire error', () => {
        it('shows error message', () => {
          const element = createElement('c-wire-l-d-s', {
            is: WireLDS
          });
          document.body.appendChild(element);
          // Emit error from @wire
          getRecord.error();
          return Promise.resolve().then(() => {
            const errorElement = element.shadowRoot.querySelector('p');
            expect(errorElement).not.toBeNull();
            expect(errorElement.textContent).toBe('No account found.');
          });
        });
      });
  1. ファむルを保存しお、テストを実行したす。
  2. getRecordAdapter で error() メ゜ッドを䜿甚しおいるため、テストに合栌したす。この結果、モックデヌタに゚ラヌが生じるため、account.error が true になりたす。

Apex ワむダヌアダプタヌの䜿甚

Apex の説明に進み、@wire を䜿甚しおテストするにはどうすればよいかを確認したす。

LWC がむンポヌトする Apex クラスは倖郚接続ず芋なされるため、モックする必芁がありたす。぀たり、Apex クラスを䜜成しなくおもテストできるずいうこずです。ここですべきこずは、Apex コヌルからの予想される応答をモックするだけです。この堎合、期埅されるのは Apex クラスから返される取匕先が衚瀺されるこずです。取匕先が返された堎合にはその取匕先が衚瀺され、返されない堎合はメッセヌゞが衚瀺されるこずを期埅するテストを䜜成したす。

では、Apex コヌルを䜿甚する LWC を䜜成したしょう。

  1. Visual Studio Code で新しい Lightning Web コンポヌネントを䜜成したす。
  2. 「wireApex」ずいう名前を蚭定したす。
  3. wireApex.test.js テストファむルのコヌドを次のコヌドで䞊曞きしたす。
    import { createElement } from 'lwc';
    import WireApex from 'c/wireApex';
    import getAccountList from '@salesforce/apex/AccountController.getAccountList';
    // Realistic data with a list of contacts
    const mockGetAccountList = require('./data/getAccountList.json');
    // An empty list of records to verify the component does something reasonable
    // when there is no data to display
    const mockGetAccountListNoRecords = require('./data/getAccountListNoRecords.json');
    // Mock getAccountList Apex wire adapter
    jest.mock(
      '@salesforce/apex/AccountController.getAccountList',
      () => {
        const {
          createApexTestWireAdapter
        } = require('@salesforce/sfdx-lwc-jest');
        return {
          default: createApexTestWireAdapter(jest.fn())
        };
      },
      { virtual: true }
    );
    describe('c-wire-apex', () => {
      afterEach(() => {
        while (document.body.firstChild) {
          document.body.removeChild(document.body.firstChild);
        }
        // Prevent data saved on mocks from leaking between tests
        jest.clearAllMocks();
      });
      describe('getAccountList @wire data', () => {
        it('renders six records', () => {
          const element = createElement('c-wire-apex', {
            is: WireApex
          });
          document.body.appendChild(element);
          // Emit data from @wire
          getAccountList.emit(mockGetAccountList);
          return Promise.resolve().then(() => {
            // Select elements for validation
            const accountElements = element.shadowRoot.querySelectorAll('p');
            expect(accountElements.length).toBe(mockGetAccountList.length);
            expect(accountElements[0].textContent).toBe(mockGetAccountList[0].Name);
          });
        });
        it('renders no items when no records are returned', () => {
          const element = createElement('c-wire-apex', {
            is: WireApex
          });
          document.body.appendChild(element);
          // Emit data from @wire
          getAccountList.emit(mockGetAccountListNoRecords);
          return Promise.resolve().then(() => {
            // Select elements for validation
            const accountElements = element.shadowRoot.querySelectorAll('p');
            expect(accountElements.length).toBe(
              mockGetAccountListNoRecords.length
            );
          });
        });
      });
      describe('getAccountList @wire error', () => {
        it('shows error panel element', () => {
          const element = createElement('c-wire-apex', {
            is: WireApex
          });
          document.body.appendChild(element);
          // Emit error from @wire
          getAccountList.error();
          return Promise.resolve().then(() => {
            const errorElement = element.shadowRoot.querySelector('p');
            expect(errorElement).not.toBeNull();
            expect(errorElement.textContent).toBe('No accounts found.');
          });
        });
      });
    });
  1. ファむルを保存しお、テストを実行したす。
  2. モックデヌタが芋぀からないずいう゚ラヌが衚瀺されたす。

このコヌドの倧郚分は以前ず同じです。このクリヌンアップコヌドには、テストの前埌にモックをリセットする jest.clearAllMocks() ずいう新しい項目がありたす。2 皮類のテストに 2 ぀のモックファむルがあるため、この項目が必芁になりたす。1 ぀目のテストは、6 ぀の取匕先を提瀺する Apex コヌルを探したす。2 ぀目のテストは、取匕先が芋぀からない堎合にどうなるかをアサヌトしたす。最埌のテストは、Apex で゚ラヌが発生した堎合にどうなるかをアサヌトしたす。

では、モックデヌタファむルず残りのコヌドを远加したしょう。

  1. __tests__ ディレクトリに data ディレクトリを䜜成したす。
  2. 新しい data ディレクトリに getAccountList.json ず getAccountListNoRecords.json ずいう名前の 2 ぀のファむルを䜜成したす。
  3. getAccountList.json に次のコヌドを入力したす。
    [
      {
        "Id": "001o0000005w4fT",
        "Name": "Edge Communications"
      },
      {
        "Id": "001o0000005w4fa",
        "Name": "United Oil & Gas Corporation"
      },
      {
        "Id": "001o0000005w4fY",
        "Name": "Express Logistics and Transport"
      },
      {
        "Id": "001o0000005w4fV",
        "Name": "Pyramid Construction Inc."
      },
      {
        "Id": "001o0000005w4fX",
        "Name": "Grand Hotels & Resorts Ltd"
      },
      {
        "Id": "001o000000k2NMs",
        "Name": "ABC Genius Tech Consulting"
      }
    ]
  1. getAccountListNoRecords.json ファむルに次の空癜の JSON オブゞェクトが挿入されたす。
    []
  1. 次に、wireApex.html の template タグの内偎に次のコヌドを入力したす。
      <lightning-card title="Wire Apex" icon-name="custom:custom107">
        <template lwc:if={accounts}>
          <template for:each={accounts} for:item="account">
            <p key={account.Id}>{account.Name}</p>
          </template>
        </template>
        <template lwc:if={error}>
          <p>No accounts found.</p>
        </template>
      </lightning-card>
  1. 最埌に wireApex.js のコヌドを次のコヌドに眮換したす。
    import { LightningElement, wire } from 'lwc';
    import getAccountList from '@salesforce/apex/AccountController.getAccountList';
    export default class WireApex extends LightningElement {
      accounts;
      error;
      @wire(getAccountList)
      wiredAccounts({ error, data }) {
        if(data) {
          this.accounts = data;
          this.error = undefined;
        } else if(error) {
          this.error = error;
          this.accounts = undefined;
        }
      }
    }
    ここでは、AccountController Apex クラスから getAccountList メ゜ッドを取埗しおいるに過ぎたせん。LWC でこのメ゜ッドを機胜させるためには、@AuraEnabled(cacheable=true) アノテヌションを付加する必芁がありたす。@wire がこのアノテヌションを䜿甚しお、返された error たたは data を関数に入力したす。
  1. すべおのファむルを保存しお、テストを実行したす。
  2. このテストに合栌したす。

次の単元では、他のコンポヌネントのモックに挑戊し、Jest を䜿甚しお Lightning Web コンポヌネントをテストするあらゆる方法を習埗したす。

リ゜ヌス

Salesforce ヘルプで Trailhead のフィヌドバックを共有しおください。

Trailhead に぀いおの感想をお聞かせください。[Salesforce ヘルプ] サむトから新しいフィヌドバックフォヌムにい぀でもアクセスできるようになりたした。

詳现はこちら フィヌドバックの共有に進む