surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4.22k stars 816 forks source link

All tests failed when running testcafe in Ubuntu #6539

Open Nisbij opened 1 year ago

Nisbij commented 1 year ago

Are you requesting a feature, reporting a bug or asking a question?

whenever I am running testcafe for the tests all of them keep failing in my environment and they all cite typeerror: cannot read property of 'undefined'

What is the current behavior?

1) An error occurred in ClientFunction code: [1] [1] TypeError: Cannot read properties of undefined (reading 'Model') [1] [1] Browser: Chrome 114.0.5735.198 / Ubuntu 22.04 [1] [1] 132 | [1] 133 | test("check expand/collapse action", async (t) => { [1] 134 | const elementTitle = Selector(".sv_qtitle"); [1] 135 | const getQuestionState = ClientFunction(() => { return window["survey"].getAllQuestions()[0].state; }); [1] 136 | [1] > 137 | await initSurvey(framework, json, { [1] 138 | onGetQuestionTitleActions: (, opt) => { }, [1] 139 | }); [1] 140 | [1] 141 | await t [1] 142 | .expect(elementTitle.hasClass("sv_q_title_expandable")).ok() [1] [1] at (/deskreen/testCafe/survey/titleActions.js:137:21) [1] at asyncGeneratorStep (/deskreen/testCafe/survey/titleActions.js:2:68) [1] at _next (/deskreen/testCafe/survey/titleActions.js:2:68) [1] at (/deskreen/testCafe/survey/titleActions.js:2:68) [1] at (/deskreen/testCafe/survey/titleActions.js:2:68) [1] at (/deskreen/testCafe/survey/titleActions.js:160:4)

What is the expected behavior?

How would you reproduce the current behavior (if this is a bug)?

Provide the test code and the tested page URL (if applicable)

Tested page URL:

Test code

FROM ubuntu:22.04
RUN apt-get update && apt-get install -y \
    git curl build-essential python3.10 python3-pip 

RUN pip install aggregate-test-results --index-url https://gitlab.lrz.de/api/v4/projects/140733/packages/pypi/simple

# Install required packages
RUN apt-get update && apt-get install -y wget && \
    apt-get -y --fix-broken install && \
    # Install Chrome dependencies
    apt-get install -y wget apt-transport-https ca-certificates && \
    # Add Chrome repository key
    wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
    # Add Chrome repository
    echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list && \
    # Install Chrome
    apt-get update && apt-get install -y google-chrome-stable && \
    apt-get clean

# Install Node.js and npm
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - && \
    apt-get install -y nodejs
RUN apt-get update && apt-get install -y autotools-dev

# Install testcafe
RUN npm install -g testcafe

# Clone the surveyjs repository and checkout a specific commit
WORKDIR /survey
RUN git clone https://github.com/surveyjs/survey-library . && \
    git checkout master
RUN npm install -g concurrently
RUN npm install -g http-server
RUN npm install -g live-server@1.2.1
#install dependencies and build the project
RUN npm install --force && \
    npm install -d http-server survey-react-ui@1.9.84
RUN ["/bin/bash", "-c", "concurrently \"npm run build_dev && live-server --port=8080 --watch=build\" \"sleep 7m && testcafe -c 4 -q chrome:headless testCafe/ --app --skip-js-errors \"http-server --silent\"\""]

RUN testcafe chrome:headless ./testcafe/

#RUN npx testcafe --skip-js-errors chrome:headless ./test/ux/Stepper.ux.ts

# Copy the test script to the container
COPY --chmod=0755 test.sh /test.sh

# Run the test script
WORKDIR /sortjs/.packages/site
ENV EXECUTIONS=25
# RUN noise-tool activate
RUN ["/bin/bash", "-c", "/test.sh $EXECUTIONS"]
# RUN noise-tool deactivate
RUN aggregate-test-results parse-junit-xml /test-results

Specify your

dk981234 commented 1 year ago

Hello, Our pipelines run testcafe tests on Ubuntu and everything works fine. Please, make sure you run npm run build_prod before running the tests. Also, I would recommend using node 14 to run the build_prod command.

Thanks, Dmitry SurveyJS Team