<?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 Re: Testing with reactiveUtils in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/testing-with-reactiveutils/m-p/1400572#M84118</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/776005"&gt;@Tom_Prutz&lt;/a&gt;, Good evening,&lt;/P&gt;&lt;P&gt;I don't know whether your question is still relevant, as you posted it almost 2 weeks ago...&lt;/P&gt;&lt;P&gt;Actually I think your code snippet should work, so we have got to find out why it is not working - as you say - in your case. You can find more information about &lt;A title="reactiveUtils | API Reference | ArcGIS Maps SDK for JavaScript 4.29 | ArcGIS Developers" href="https://developers.arcgis.com/javascript/latest/api-reference/esri-core-reactiveUtils.html" target="_blank" rel="noopener"&gt;reactiveUtils in the ArcGIS JS API Reference&lt;/A&gt;, and there it is suggested to put a question mark behind view. But I did test your sample without a question mark, and that did the job as well...&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;reactiveUtils.when(
  () =&amp;gt; view?.stationary === true,
  () =&amp;gt; {
    console.log("view is stationary now");
  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To see a working example you have a look at this blogpost &lt;A href="https://community.esri.com/t5/gis-life-blog/arcgis-javascript-with-uk-data-url-searchparams/ba-p/898659" target="_blank"&gt;ArcGIS JavaScript with UK data - URL.searchParams&lt;/A&gt;. It might seem an older post, but I just updated it tonight, to use &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;reactiveUtils&lt;/FONT&gt;&lt;/STRONG&gt; (instead of the &lt;SPAN&gt;deprecated, and now even completely removed, &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;watchUtils&lt;/FONT&gt;&lt;/STRONG&gt; which I used in an earlier version of the post). As you can see, the parameters in the URL are updated every time the view becomes stationary. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So, in the end, the conclusion might be, that your issue is caused by your test setup. Can you please provide us with more information/code to explain what you are trying to do?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Egge-Jan&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Mar 2024 20:13:52 GMT</pubDate>
    <dc:creator>Egge-Jan_Pollé</dc:creator>
    <dc:date>2024-03-25T20:13:52Z</dc:date>
    <item>
      <title>Testing with reactiveUtils</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/testing-with-reactiveutils/m-p/1396014#M84010</link>
      <description>&lt;P&gt;I am currently working on a part of our application that will display a subset of topo data under certain circumstances. I am trying to test part of that functionality but I am currently unable to get my code to run in a test.&lt;/P&gt;&lt;P&gt;I am quite new to the esri stack and particularly front end testing so it is possible I'm doing something wrong or misunderstanding a concept, however a lot of trial and error and Google searching hasn't turned anything up.&lt;/P&gt;&lt;P&gt;At the most basic level my issue is that I can't get the watcher created by a reactiveUtils instance to trigger.&lt;/P&gt;&lt;P&gt;I have a MapView that is passed into my function I then have code that looks like this&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;reactiveUtils&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;when&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; () &lt;/SPAN&gt;&lt;SPAN&gt;=&amp;gt;&lt;/SPAN&gt; &lt;SPAN&gt;view&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;stationary&lt;/SPAN&gt; &lt;SPAN&gt;===&lt;/SPAN&gt; &lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; () &lt;/SPAN&gt;&lt;SPAN&gt;=&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;do stuff&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;});&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I am mocking the view and as such when I pass it in I can confirm that the value of stationary is true. I hoped that would cause the code inside that reactiveUtils to trigger but it does not. I have verified that the value is true at that point and that no code inside is running.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;At this stage I'm at a loss. I don't know if it is possible to trigger my mock to start false and then switch true at the right time. I suspect not as the test would finish before that could occur. Equally I don't know how to mock out or otherwise trigger that reactiveUtils.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;An option is to pull the code inside, out and test that separately but that then does not encompass everything I want to test. Another option would be to feed in a real view and simulate it being moved. That is a bigger scope than what I am trying to do here.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Can anyone suggest an option for how I can get this to work? Happy to provide more information/code if that will help. There seems to be a general lack of documentation around using things like these in tests, does such documentation exist and if so please could someone point me towards it?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 14 Mar 2024 16:10:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/testing-with-reactiveutils/m-p/1396014#M84010</guid>
      <dc:creator>Tom_Prutz</dc:creator>
      <dc:date>2024-03-14T16:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: Testing with reactiveUtils</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/testing-with-reactiveutils/m-p/1400572#M84118</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/776005"&gt;@Tom_Prutz&lt;/a&gt;, Good evening,&lt;/P&gt;&lt;P&gt;I don't know whether your question is still relevant, as you posted it almost 2 weeks ago...&lt;/P&gt;&lt;P&gt;Actually I think your code snippet should work, so we have got to find out why it is not working - as you say - in your case. You can find more information about &lt;A title="reactiveUtils | API Reference | ArcGIS Maps SDK for JavaScript 4.29 | ArcGIS Developers" href="https://developers.arcgis.com/javascript/latest/api-reference/esri-core-reactiveUtils.html" target="_blank" rel="noopener"&gt;reactiveUtils in the ArcGIS JS API Reference&lt;/A&gt;, and there it is suggested to put a question mark behind view. But I did test your sample without a question mark, and that did the job as well...&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;reactiveUtils.when(
  () =&amp;gt; view?.stationary === true,
  () =&amp;gt; {
    console.log("view is stationary now");
  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To see a working example you have a look at this blogpost &lt;A href="https://community.esri.com/t5/gis-life-blog/arcgis-javascript-with-uk-data-url-searchparams/ba-p/898659" target="_blank"&gt;ArcGIS JavaScript with UK data - URL.searchParams&lt;/A&gt;. It might seem an older post, but I just updated it tonight, to use &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;reactiveUtils&lt;/FONT&gt;&lt;/STRONG&gt; (instead of the &lt;SPAN&gt;deprecated, and now even completely removed, &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;watchUtils&lt;/FONT&gt;&lt;/STRONG&gt; which I used in an earlier version of the post). As you can see, the parameters in the URL are updated every time the view becomes stationary. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So, in the end, the conclusion might be, that your issue is caused by your test setup. Can you please provide us with more information/code to explain what you are trying to do?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Egge-Jan&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 20:13:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/testing-with-reactiveutils/m-p/1400572#M84118</guid>
      <dc:creator>Egge-Jan_Pollé</dc:creator>
      <dc:date>2024-03-25T20:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Testing with reactiveUtils</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/testing-with-reactiveutils/m-p/1401492#M84137</link>
      <description>&lt;P&gt;Thank you for coming back to me. I had to pivot a bit as I ran out of ideas and with the help of an Esri consultant we did manage to get it working by mocking out the reactiveUtils so from a practical stand point this is now resolved.&lt;/P&gt;&lt;P&gt;I suspect you may have been correct about the test setup and I will bear that in mind for the future.&amp;nbsp; Many Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2024 15:11:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/testing-with-reactiveutils/m-p/1401492#M84137</guid>
      <dc:creator>Tom_Prutz</dc:creator>
      <dc:date>2024-03-27T15:11:23Z</dc:date>
    </item>
  </channel>
</rss>

