docs/assets/js/97535711.5ff04a3a.js
"use strict";(self.webpackChunkdocs_openc3_com=self.webpackChunkdocs_openc3_com||[]).push([[437],{9839:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>o,contentTitle:()=>r,default:()=>h,frontMatter:()=>l,metadata:()=>c,toc:()=>a});var t=s(4848),i=s(8453);const l={title:"Testing COSMOS"},r=void 0,c={id:"development/testing",title:"Testing COSMOS",description:"Playwright",source:"@site/docs/development/testing.md",sourceDirName:"development",slug:"/development/testing",permalink:"/docs/development/testing",draft:!1,unlisted:!1,editUrl:"https://github.com/OpenC3/cosmos/tree/main/docs.openc3.com/docs/development/testing.md",tags:[],version:"current",frontMatter:{title:"Testing COSMOS"},sidebar:"defaultSidebar",previous:{title:"Streaming API",permalink:"/docs/development/streaming-api"},next:{title:"Meta",permalink:"/docs/meta"}},o={},a=[{value:"Playwright",id:"playwright",level:2},{value:"Prerequesits",id:"prerequesits",level:3},{value:"Playwright Testing",id:"playwright-testing",level:3},{value:"Unit Tests",id:"unit-tests",level:2}];function d(e){const n={code:"code",em:"em",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",...(0,i.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.h2,{id:"playwright",children:"Playwright"}),"\n",(0,t.jsx)(n.h3,{id:"prerequesits",children:"Prerequesits"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"Install Yarn"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"npm install --global yarn\n"})}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"Clone the COSMOS Playwright repo"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"git clone https://github.com/OpenC3/cosmos-playwright\n"})}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"Install Playwright and dependencies"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"cosmos-playwright % yarn install\n"})}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.h3,{id:"playwright-testing",children:"Playwright Testing"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"Start COSMOS"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"cosmos % openc3.sh start\n"})}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:'Open COSMOS in your browser. At the login screen, set the password to "password".'}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"Run tests (Note the --headed option visually displays tests, leave it off to run in the background)"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"cosmos-playwright % yarn playwright test --project=chromium --headed\n"})}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.em,{children:"[Optional]"})," Fix istanbul/nyc coverage source lookups (use ",(0,t.jsx)(n.code,{children:"fixwindows"})," if not on Linux)."]}),"\n",(0,t.jsx)(n.p,{children:"Tests will run successfully without this step and you will get coverage statistics, but line-by-line coverage won't work."}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"cosmos-playwright % yarn fixlinux\n"})}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"Generate code coverage"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"cosmos-playwright % yarn coverage\n"})}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:["Code coverage reports can be viewed at ",(0,t.jsx)(n.code,{children:"openc3-playwright/coverage/index.html"})]}),"\n",(0,t.jsx)(n.h2,{id:"unit-tests",children:"Unit Tests"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsxs)(n.p,{children:["Navigate to ",(0,t.jsx)(n.strong,{children:"cosmos/openc3"})," folder. Run the command:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"cosmos/openc3 % rake build\ncosmos/openc3 % bundle exec rspec\n"})}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:["Code coverage reports can be found at ",(0,t.jsx)(n.code,{children:"cosmos/openc3/coverage/index.html"})]})]})}function h(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(d,{...e})}):d(e)}},8453:(e,n,s)=>{s.d(n,{R:()=>r,x:()=>c});var t=s(6540);const i={},l=t.createContext(i);function r(e){const n=t.useContext(l);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),t.createElement(l.Provider,{value:n},e.children)}}}]);