title: How testing svelte components
body: <p>There is a component that uses a third-party module
  We need to test it, it is desirable not to make a mock component that is imported into it.
  Wrote on this example</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// test.spec.ts
  import Component from "Component";
  
  describe('Component', () =&gt; {
      test('should render component correctly', () =&gt; {
          const { container } = render(Component);
          expect(container).toBeTruthy();
      });
  });
  
  // error: TypeError: cn is not a function</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>// ChildComponent.svelte
  
  &lt;script type="ts"&gt;
    import cn from 'clsx';
    const class = cn('
      'awesome-class': true
    ');
  &lt;/script&gt;
  
  &lt;div {class} &gt;&lt;/div&gt;
  
  
  
  // Component.svelte
  
  &lt;script type="ts"&gt;
    import ChildComponent from './ChildComponen';
  &lt;/script&gt;
  
  &lt;ChildComponent /&gt;
  
  jest.config.js looks like this</code></pre>
  </div>
  </div>
  </p>
  <pre><code>/// jest.config.js
  module.exports = {
      displayName: { name: 'web', color: 'magentaBright' },
      preset: 'ts-jest',
      testEnvironment: 'jsdom',
      testRegex: '\\.spec\\.ts?$',
      coverageDirectory: 'src',
      moduleDirectories: ['node_modules', 'src', '&lt;rootDir&gt;'],
  
      moduleNameMapper: {
          '^src(.*)$': '&lt;rootDir&gt;/src$1',
          clxs: '&lt;rootDir&gt;/node_modules/clxs',
      },
      transform: {
          '^.+\\.svelte$': ['svelte-jester', { preprocess: true }],
          '^.+\\.js$': 'babel-jest'
      },
      moduleFileExtensions: ['js', 'ts', 'svelte'],
      bail: false,
      verbose: true,
      testTimeout: 3000,
      setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
  };
  </code></pre>
  <p>Is it possible to test a component without mock others depreciating into that component?</p>