<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Testing arcgis/core in React with Storybook in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/testing-arcgis-core-in-react-with-storybook/m-p/1395109#M83984</link>
    <description>&lt;P&gt;Hello &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I am using &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/642472"&gt;@ArcGIS&lt;/a&gt;/core package in React web application. I also use Storybook for testing.&lt;/P&gt;&lt;P&gt;I have a case (multiple cases actually) when I subscribe to MapView (like through mapView.on('click', () =&amp;gt; {...}) ) ) inside useEffect to react to occurred click events. So every time there is an event I am interested in, I set state through useState or send xstate event to my machine if needed. The way I do that doesn't matter that much, what matters is how I can test that behaviour... In the typical UI you use Testing Library utilities like screen.getByText() etc to grab a specific HTML element and simulate click through userEvent.click(), but when the map is one big canvas element, those selectors are useless. So in order to make everything testable I need to somehow emit the event on MapView instance. And it seems to me there is no way in v4 of&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/642472"&gt;@ArcGIS&lt;/a&gt;/core to do that -&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/emit-click-event-in-4-x/m-p/723572" target="_blank"&gt;Solved: emit click event in 4.x - Esri Community&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;So my question is how I should test my functionality where I use ArcGIS models like MapView? If I cannot use mapView.emit(), then how I can simulate the map click event in the specific place to make sure that for instance I use SketchViewModel properly and that my React components align with those events emitted by map clicks?&lt;/P&gt;&lt;P&gt;This is really critical IMHO because I cannot test my software which uses&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/642472"&gt;@ArcGIS&lt;/a&gt;/core package.&lt;/P&gt;&lt;P&gt;Thanks for response in advance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Mar 2024 07:21:56 GMT</pubDate>
    <dc:creator>Bart</dc:creator>
    <dc:date>2024-03-13T07:21:56Z</dc:date>
    <item>
      <title>Testing arcgis/core in React with Storybook</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/testing-arcgis-core-in-react-with-storybook/m-p/1395109#M83984</link>
      <description>&lt;P&gt;Hello &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I am using &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/642472"&gt;@ArcGIS&lt;/a&gt;/core package in React web application. I also use Storybook for testing.&lt;/P&gt;&lt;P&gt;I have a case (multiple cases actually) when I subscribe to MapView (like through mapView.on('click', () =&amp;gt; {...}) ) ) inside useEffect to react to occurred click events. So every time there is an event I am interested in, I set state through useState or send xstate event to my machine if needed. The way I do that doesn't matter that much, what matters is how I can test that behaviour... In the typical UI you use Testing Library utilities like screen.getByText() etc to grab a specific HTML element and simulate click through userEvent.click(), but when the map is one big canvas element, those selectors are useless. So in order to make everything testable I need to somehow emit the event on MapView instance. And it seems to me there is no way in v4 of&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/642472"&gt;@ArcGIS&lt;/a&gt;/core to do that -&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/emit-click-event-in-4-x/m-p/723572" target="_blank"&gt;Solved: emit click event in 4.x - Esri Community&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;So my question is how I should test my functionality where I use ArcGIS models like MapView? If I cannot use mapView.emit(), then how I can simulate the map click event in the specific place to make sure that for instance I use SketchViewModel properly and that my React components align with those events emitted by map clicks?&lt;/P&gt;&lt;P&gt;This is really critical IMHO because I cannot test my software which uses&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/642472"&gt;@ArcGIS&lt;/a&gt;/core package.&lt;/P&gt;&lt;P&gt;Thanks for response in advance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 07:21:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/testing-arcgis-core-in-react-with-storybook/m-p/1395109#M83984</guid>
      <dc:creator>Bart</dc:creator>
      <dc:date>2024-03-13T07:21:56Z</dc:date>
    </item>
  </channel>
</rss>

