<?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: how to execute test for &amp;quot;simple&amp;quot; sample custom widget? in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-execute-test-for-quot-simple-quot-sample/m-p/1078054#M2392</link>
    <description>&lt;P&gt;Thanks again Grant.&amp;nbsp; It seemed like I just had to re-arrange the imports in&amp;nbsp;&lt;SPAN&gt;client/jimu-for-test/setup-jest.js to:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;require('jest-fetch-mock').enableMocks()
const { System } = require('systemjs');
global.systemRegister = System.register;
const Enzyme = require('enzyme');
const Adapter = require('@wojtekmaj/enzyme-adapter-react-17')
Enzyme.configure({ adapter: new Adapter() });&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 12 Jul 2021 22:31:34 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-07-12T22:31:34Z</dc:date>
    <item>
      <title>how to execute test for "simple" sample custom widget?</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-execute-test-for-quot-simple-quot-sample/m-p/1077529#M2377</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;I'm trying to run the test provided w/ the sample custom widget "simple".&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm assuming that I need to create a package.json and install some dependencies but not clear on what and I don't see documentation on&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="andale mono,times"&gt;jimu-for-test&lt;/FONT&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can someone please point me in the right direction?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;--john&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jul 2021 21:45:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-execute-test-for-quot-simple-quot-sample/m-p/1077529#M2377</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-07-10T21:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to execute test for "simple" sample custom widget?</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-execute-test-for-quot-simple-quot-sample/m-p/1077531#M2378</link>
      <description>&lt;P&gt;There are already scripts in the package.json to run the tests.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can execute them using the following commands by executing them in the client folder.&lt;/P&gt;&lt;P&gt;npm run test&lt;/P&gt;&lt;P&gt;or&amp;nbsp;&lt;/P&gt;&lt;P&gt;for the watch&lt;/P&gt;&lt;P&gt;npm run test:watch&lt;/P&gt;&lt;P&gt;I've pushed these both out in to .bat files to make it simpler to execute them. I;ve been writing a few tests recently and was planning on putting together a cheat sheet on the complications I've found so far when wrting unit tests for custom widgets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jul 2021 21:53:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-execute-test-for-quot-simple-quot-sample/m-p/1077531#M2378</guid>
      <dc:creator>Grant-S-Carroll</dc:creator>
      <dc:date>2021-07-10T21:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to execute test for "simple" sample custom widget?</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-execute-test-for-quot-simple-quot-sample/m-p/1077549#M2379</link>
      <description>&lt;P&gt;Thanks for your suggestion Grant.&amp;nbsp; When I try, I get the error:&lt;/P&gt;&lt;LI-CODE lang="c"&gt; FAIL  your-extensions/widgets/simple/tests/simple-widget.test.tsx
  ● Test suite failed to run

    TypeError: global.systemRegister is not a function&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jul 2021 03:44:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-execute-test-for-quot-simple-quot-sample/m-p/1077549#M2379</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-07-11T03:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to execute test for "simple" sample custom widget?</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-execute-test-for-quot-simple-quot-sample/m-p/1077615#M2386</link>
      <description>&lt;P&gt;Hi John&lt;/P&gt;&lt;P&gt;Right, sorry about that. Looks like there is an issue with the setup-test.js file under the folder, client/jimu-for-test/setup-jest.js&lt;/P&gt;&lt;P&gt;I've modifed this to match what I have in ExB 1.2 see below, basically commented out the Enzyme imports.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;require('jest-fetch-mock').enableMocks()
const { System } = require('systemjs');
//const Enzyme = require('enzyme');
//const Adapter = require('@wojtekmaj/enzyme-adapter-react-17')
//Enzyme.configure({ adapter: new Adapter() });

global.systemRegister = System.register;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I havent had a chance to dig any deeper, but i suspect its and issue with the Enzyme or Adapter imports. What this means that in your tests you may have to import them like below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import { React } from 'jimu-core';
import _Widget from '../src/runtime/widget';
import { widgetRender, wrapWidget } from 'jimu-for-test';

//Configure Enzyme here
const Enzyme = require('enzyme');
const Adapter = require('@wojtekmaj/enzyme-adapter-react-17')
Enzyme.configure({ adapter: new Adapter() });

const render = widgetRender();
describe('test simple widget', () =&amp;gt; {
  it('simple test', () =&amp;gt; {
    const Widget = wrapWidget(_Widget, {
      config: {exampleConfigProperty: 'a'},
    });
    const {queryByText} = render(&amp;lt;Widget widgetId="Widget_1" /&amp;gt;);
    expect(queryByText('exampleConfigProperty: a').tagName).toBe('P');
  })
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, with the above changes I was able to get the out of the box test to run.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jul 2021 20:45:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-execute-test-for-quot-simple-quot-sample/m-p/1077615#M2386</guid>
      <dc:creator>Grant-S-Carroll</dc:creator>
      <dc:date>2021-07-11T20:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to execute test for "simple" sample custom widget?</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-execute-test-for-quot-simple-quot-sample/m-p/1078054#M2392</link>
      <description>&lt;P&gt;Thanks again Grant.&amp;nbsp; It seemed like I just had to re-arrange the imports in&amp;nbsp;&lt;SPAN&gt;client/jimu-for-test/setup-jest.js to:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;require('jest-fetch-mock').enableMocks()
const { System } = require('systemjs');
global.systemRegister = System.register;
const Enzyme = require('enzyme');
const Adapter = require('@wojtekmaj/enzyme-adapter-react-17')
Enzyme.configure({ adapter: new Adapter() });&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 12 Jul 2021 22:31:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-execute-test-for-quot-simple-quot-sample/m-p/1078054#M2392</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-07-12T22:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to execute test for "simple" sample custom widget?</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-execute-test-for-quot-simple-quot-sample/m-p/1078055#M2393</link>
      <description>&lt;P&gt;Nice, will update my 1.4 instance to match.&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 22:35:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/how-to-execute-test-for-quot-simple-quot-sample/m-p/1078055#M2393</guid>
      <dc:creator>Grant-S-Carroll</dc:creator>
      <dc:date>2021-07-12T22:35:06Z</dc:date>
    </item>
  </channel>
</rss>

