2016-08-11 7 views
1

chimp를 사용하여 mocha 테스트를 실행하는 node.js 응용 프로그램이 있으며 내 로컬 OS에서 실행할 때 정상적으로 작동합니다. Google 크롬을 사용하여 UI 테스트를 수행합니다.도커 컨테이너에서 헤드리스 브라우저 테스트를 실행하는 방법

현재이 응용 프로그램을 독점하고 있습니다 ... 그러나 브라우저 측면에서 UI 테스트를 실행하려면 무엇이 필요한지 확신 할 수 없습니다.

머리가없는 크롬 브라우저를 설치하기 위해 https://github.com/workflow/docker-chimp/blob/master/Dockerfile의 명령 중 일부를 사용했습니다.

내 테스트가 "이전"테스트에서 실패합니다 ...하지만 그 이유는 무엇인지, 또는 왜 발생하는지에 대해서는 잘 모릅니다. 테스트는 호스트 OS에서 정상적으로 실행됩니다.

> [email protected] test /PlutoD2D/itest 
> chimp --mocha 


[chimp] Running... 


    1) "before all" hook 

    0 passing (1m) 
    1 failing 

    1) "before all" hook: 
    Error: timeout of 60000ms exceeded. Ensure the done() callback is being called in this test 




Mocha failed 
npm ERR! Test failed. See above for more details. 

어떻게 문제를 찾을 수 있습니까?

+1

try --debug 플래그. 또한이 내용은 https://medium.com/lucjuggery/using-chimp-to-test-a-docker-compose-application-a258a610a57e#.h58qbe7el –

+0

을 참조하십시오. 해결책은 권한으로 실행하거나 xvfb를 사용하는 것입니다 (더 나은) –

답변

0

mocha-headless-chrome 패키지를 사용해보세요.

apt-get install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget 

details를 참조하십시오 : 고정 표시기 컨테이너에서 헤드리스 크롬을 실행하기위한

npm i mocha-headless-chrome 

mocha-headless-chrome -f test-page.html 

또한 일부 라이브러리가 필요합니다.

관련 문제