Trendyol/baklava

[BUG]: When we write our tests in our react and vit project, we get errors on the jest side.

bbalozgur opened this issue · 0 comments

Issue description

Test suite failed to run

Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

By default "node_modules" folder is ignored by transformers.

Here's what you can do:
 • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
 • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
 • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
 • If you need a custom transformation specify a "transform" option in your config.
 • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation

Details:

/Users/ozgur.bal/trendyol-projects/experimentation-platform-ui/node_modules/@trendyol/baklava/dist/baklava-react.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import"./chunk-VO7C5OZC.js";var h=new Set(["children","localName","ref","style","className"]),g=new WeakMap,v=(n,m,s,i,d)=>{let B=d==null?void 0:d[m];B===void 0||s===i?(n[m]=s,s==null&&m in HTMLElement.prototype&&n.removeAttribute(m)):((c,a,p)=>{let r=g.get(c);r===void 0&&g.set(c,r=new Map);let l=r.get(a);p!==void 0?l===void 0?(r.set(a,l={handleEvent:p}),c.addEventListener(a,l)):l.handleEvent=p:l!==void 0&&(r.delete(a),c.removeEventListener(a,l))})(n,B,s)},t=({react:n,tagName:m,elementClass:s,events:i,displayName:d})=>{let B=new Set(Object.keys(i!=null?i:{})),c=n.forwardRef((a,p)=>{let r=n.useRef(null),l=n.useRef(null),u={},y={};for(let[o,b]of Object.entries(a))h.has(o)?u[o==="className"?"class":o]=b:B.has(o)||o in s.prototype?y[o]=b:u[o]=b;return n.useLayoutEffect(()=>{if(l.current!==null){for(let o in y)v(l.current,o,a[o],r.current?r.current[o]:void 0,i);r.current=a}}),n.useLayoutEffect(()=>{var o;(o=l.current)===null||o===void 0||o.removeAttribute("defer-hydration")},[]),u.suppressHydrationWarning=!0,n.createElement(m,{...u,ref:o=>{l.current=o,typeof p=="function"?p(o):p!==null&&(p.current=o)}})});return c.displayName=d!=null?d:s.name,c};import e from"react";var D=e.lazy(()=>customElements.whenDefined("bl-alert").then(()=>({default:t({react:e,displayName:"BlAlert",tagName:"bl-alert",elementClass:customElements.get("bl-alert"),events:{onBlClose:"bl-close"}})}))),f=e.lazy(()=>customElements.whenDefined("bl-badge").then(()=>({default:t({react:e,displayName:"BlBadge",tagName:"bl-badge",elementClass:customElements.get("bl-badge"),events:{}})}))),N=e.lazy(()=>customElements.whenDefined("bl-button").then(()=>({default:t({react:e,displayName:"BlButton",tagName:"bl-button",elementClass:customElements.get("bl-button"),events:{onBlClick:"bl-click"}})}))),k=e.lazy(()=>customElements.whenDefined("bl-checkbox-group").then(()=>({default:t({react:e,displayName:"BlCheckboxGroup",tagName:"bl-checkbox-group",elementClass:customElements.get("bl-checkbox-group"),events:{onBlCheckboxGroupChange:"bl-checkbox-group-change"}})}))),I=e.lazy(()=>customElements.whenDefined("bl-dialog").then(()=>({default:t({react:e,displayName:"BlDialog",tagName:"bl-dialog",elementClass:customElements.get("bl-dialog"),events:{onBlDialogOpen:"bl-dialog-open",onBlDialogRequestClose:"bl-dialog-request-close",onBlDialogClose:"bl-dialog-close"}})}))),S=e.lazy(()=>customElements.whenDefined("bl-drawer").then(()=>({default:t({react:e,displayName:"BlDrawer",tagName:"bl-drawer",elementClass:customElements.get("bl-drawer"),events:{onBlDrawerOpen:"bl-drawer-open",onBlDrawerClose:"bl-drawer-close"}})}))),P=e.lazy(()=>customElements.whenDefined("bl-dropdown").then(()=>({default:t({react:e,displayName:"BlDropdown",tagName:"bl-dropdown",elementClass:customElements.get("bl-dropdown"),events:{onBlDropdownOpen:"bl-dropdown-open",onBlDropdownClose:"bl-dropdown-close"}})}))),G=e.lazy(()=>customElements.whenDefined("bl-icon").then(()=>({default:t({react:e,displayName:"BlIcon",tagName:"bl-icon",elementClass:customElements.get("bl-icon"),events:{onBlLoad:"bl-load",onBlError:"bl-error"}})}))),O=e.lazy(()=>customElements.whenDefined("bl-input").then(()=>({default:t({react:e,displayName:"BlInput",tagName:"bl-input",elementClass:customElements.get("bl-input"),events:{onBlChange:"bl-change",onBlInput:"bl-input",onBlInvalid:"bl-invalid"}})}))),R=e.lazy(()=>customElements.whenDefined("bl-pagination").then(()=>({default:t({react:e,displayName:"BlPagination",tagName:"bl-pagination",elementClass:customElements.get("bl-pagination"),events:{onBlChange:"bl-change"}})}))),z=e.lazy(()=>customElements.whenDefined("bl-popover").then(()=>({default:t({react:e,displayName:"BlPopover",tagName:"bl-popover",elementClass:customElements.get("bl-popover"),events:{onBlPopoverShow:"bl-popover-show",onBlPopoverHide:"bl-popover-hide"}})}))),F=e.lazy(()=>customElements.whenDefined("bl-progress-indicator").then(()=>({default:t({react:e,displayName:"BlProgressIndicator",tagName:"bl-progress-indicator",elementClass:customElements.get("bl-progress-indicator"),events:{}})}))),A=e.lazy(()=>customElements.whenDefined("bl-radio-group").then(()=>({default:t({react:e,displayName:"BlRadioGroup",tagName:"bl-radio-group",elementClass:customElements.get("bl-radio-group"),events:{onBlRadioChange:"bl-radio-change"}})}))),H=e.lazy(()=>customElements.whenDefined("bl-select").then(()=>({default:t({react:e,displayName:"BlSelect",tagName:"bl-select",elementClass:customElements.get("bl-select"),events:{onBlSelect:"bl-select"}})}))),L=e.lazy(()=>customElements.whenDefined("bl-switch").then(()=>({default:t({react:e,displayName:"BlSwitch",tagName:"bl-switch",elementClass:customElements.get("bl-switch"),events:{onBlSwitchToggle:"bl-switch-toggle"}})}))),q=e.lazy(()=>customElements.whenDefined("bl-tab-group").then(()=>({default:t({react:e,displayName:"BlTabGroup",tagName:"bl-tab-group",elementClass:customElements.get("bl-tab-group"),events:{}})}))),j=e.lazy(()=>customElements.whenDefined("bl-textarea").then(()=>({default:t({react:e,displayName:"BlTextarea",tagName:"bl-textarea",elementClass:customElements.get("bl-textarea"),events:{onBlInput:"bl-input",onBlChange:"bl-change",onBlInvalid:"bl-invalid"}})}))),M=e.lazy(()=>customElements.whenDefined("bl-tooltip").then(()=>({default:t({react:e,displayName:"BlTooltip",tagName:"bl-tooltip",elementClass:customElements.get("bl-tooltip"),events:{onBlTooltipShow:"bl-tooltip-show",onBlTooltipHide:"bl-tooltip-hide"}})}))),V=e.lazy(()=>customElements.whenDefined("bl-checkbox").then(()=>({default:t({react:e,displayName:"BlCheckbox",tagName:"bl-checkbox",elementClass:customElements.get("bl-checkbox"),events:{onBlCheckboxChange:"bl-checkbox-change",onBlFocus:"bl-focus",onBlBlur:"bl-blur"}})}))),W=e.lazy(()=>customElements.whenDefined("bl-dropdown-group").then(()=>({default:t({react:e,displayName:"BlDropdownGroup",tagName:"bl-dropdown-group",elementClass:customElements.get("bl-dropdown-group"),events:{}})}))),J=e.lazy(()=>customElements.whenDefined("bl-dropdown-item").then(()=>({default:t({react:e,displayName:"BlDropdownItem",tagName:"bl-dropdown-item",elementClass:customElements.get("bl-dropdown-item"),events:{onBlDropdownItemClick:"bl-dropdown-item-click"}})}))),K=e.lazy(()=>customElements.whenDefined("bl-radio").then(()=>({default:t({react:e,displayName:"BlRadio",tagName:"bl-radio",elementClass:customElements.get("bl-radio"),events:{onBlChecked:"bl-checked",onBlFocus:"bl-focus",onBlBlur:"bl-blur"}})}))),Q=e.lazy(()=>customElements.whenDefined("bl-select-option").then(()=>({default:t({react:e,displayName:"BlSelectOption",tagName:"bl-select-option",elementClass:customElements.get("bl-select-option"),events:{onBlSelectOption:"bl-select-option",onBlFocus:"bl-focus",onBlBlur:"bl-blur"}})}))),U=e.lazy(()=>customElements.whenDefined("bl-tab").then(()=>({default:t({react:e,displayName:"BlTab",tagName:"bl-tab",elementClass:customElements.get("bl-tab"),events:{onBlTabSelected:"bl-tab-selected"}})}))),X=e.lazy(()=>customElements.whenDefined("bl-tab-panel").then(()=>({default:t({react:e,displayName:"BlTabPanel",tagName:"bl-tab-panel",elementClass:customElements.get("bl-tab-panel"),events:{}})})));export{D as BlAlert,f as BlBadge,N as BlButton,V as BlCheckbox,k as BlCheckboxGroup,I as BlDialog,S as BlDrawer,P as BlDropdown,W as BlDropdownGroup,J as BlDropdownItem,G as BlIcon,O as BlInput,R as BlPagination,z as BlPopover,F as BlProgressIndicator,K as BlRadio,A as BlRadioGroup,H as BlSelect,Q as BlSelectOption,L as BlSwitch,U as BlTab,q as BlTabGroup,X as BlTabPanel,j as BlTextarea,M as BlTooltip};
                                                                                  ^^^^^^

SyntaxError: Cannot use import statement outside a module

  1 | import { Row, Col, Form, Typography } from 'antd';
> 2 | import { BlInput, BlButton } from '@trendyol/baklava/dist/baklava-react';
    | ^
  3 |
  4 | import styles from './UserLoginForm.module.scss';

Media & Screenshots

No response

Baklava Version

No response

Operating system

  • OS: [e.g. iOS]:

  • Browser [e.g. chrome, safari]:

  • Any other details...

Priority this issue should have

Low (slightly annoying)

Please review the checkboxes that are applicable.

  • This issue is directly related to React