CircleCI is one of the most renowned CI/CD tools due to its an easy-to-use interface, simplistic configuration, along with the huge support for numerous libraries and services. CircleCI ensures that your code deployment is of high quality, and in less time. It does so by passing every commit to run through your automated pipeline before pushing it to the respective feature branch. So if anything goes south, then you know instantly where to look for. This helps in preventing a major breakdown by eliminating any bottleneck at an early stage. CircleCI facilitates rapid as well as robust fixes at scale.
LambdaTest now integrates with CircleCI to boost your go-to-market delivery. Perform automated cross browser testing with LambdaTest to ensure your development code renders seamlessly through an online Selenium grid providing 2000+ real browsers running through machines, on the cloud. Perform automation testing in parallel with LambdaTest’s Selenium grid to drastically trim down your test cycles.
In order to perform your karma tests with LambdaTest, you would need the below things to be already set up:
1 |
$ brew install node |
1 |
npm install npm@latest -g |
1 2 |
$ export LT_USERNAME=<your lambdatest username> $ export LT_ACCESS_KEY=<your lambdatest access_key> |
To integrate CircleCI with LambdaTest you need to make minor tweaks in the .circleci/config.yml which is the configuration file for your CircleCI instance. The changes you need to make will revolve around the environment variables such as access key, username, grid config and so on. Refer to CircleCI documentation for more information regarding the set up of environment variables.
Below is a sample config file for integrating CircleCI with LambdaTest. You can use the sample file to test your own automation test suite by replacing the environment variables according to your need. All the code used for the demonstration of this topic can be find in our GitHub repository.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# Javascript Node CircleCI 2.0 configuration file # Check https://circleci.com/docs/2.0/language-javascript/ for more details version: 2 jobs: build: docker: # specify the version you desire here - image: circleci/node:7.10 # Specify service dependencies here if necessary # CircleCI maintains a library of pre-built images # documented at https://circleci.com/docs/2.0/circleci-images/ # the working dir is github repo that you need to fork to become owner. working_directory: ~/nightwatch-saple-for-circleci steps: - checkout - run: name: "Setup custom environment variables // its your workflow step" command: | echo 'export LT_USERNAME="{your_lambdatest_username}"' >> $BASH_ENV - run: name: "Setup custom environment variables" command: | echo 'export LT_ACCESS_KEY="{your_lambda_access_key}"' >> $BASH_ENV - run: # Validating your above mentioned environment variables name: "Here is the LT_Username : " command: echo ${LT_USERNAME} # Download and cache dependencies - restore_cache: keys: - v1-dependencies-{{ checksum "package.json" }} # fallback to using the latest cache if no exact match is found - run: npm install # run tests! - run: node_modules/.bin/nightwatch -e chrome // Executing test in bash. |
LambdaTest offers a Selenium Desired Capabilities Generator to fetch coded values for your desired test configurations.
For Instance, if you select the below configurations:
Then Capabilities Generator at LambdaTest will provide you with the below program:
1 2 3 4 5 6 7 8 9 10 11 |
var capabilities = { "build" : "your build name", //You can edit this and assign a build name "name" : "your test name", // Assign a name to your Test "platform" : "Windows 8.1", // The operating system on which you want to test your website "browserName" : "Firefox", // The browser on which you want to test "version" : "62.0", // The browser version which you've selected to perform the test upon "resolution" : "1280x1024", // The resolution in which you want to run the test as per your operating system "selenium_version" : "3.11.0", //The version of Selenium on which the test will run "visual" : true, "firefox.driver" : v0.21.0 } |
For more information, refer to our documentation on Selenium Automation Capabilities.
To help you perform cross browser testing of your locally stored web pages, LambdaTest provides an SSH(Secure Shell) tunnel connection with the name Lambda Tunnel. With Lambda Tunnel, you can execute a test server inside your CircleCI build container to perform automated cross browser testing on browsers offered by Selenium grid on LambdaTest. So you make sure how well your changes look, even before your customers. Curious to know more about Lambda Tunnel?
Follow our documentation on Lambda Tunnel to know it all. OS specific instructions to download and setup tunnel binary can be found at the following links.
Download the binary file of:
The below example of config.yml file would demonstrate you on how to leverage LambdaTest’s Selenium grid by performing a browser test through your testing server contained in your CircleCI build.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# Javascript Node CircleCI 2.0 configuration file # # Check https://circleci.com/docs/2.0/language-javascript/ for more details # version: 2 jobs: build: docker: # specify the version you desire here - image: circleci/node:7.10 # Specify service dependencies here if necessary working_directory: ~/Nightwatch-circleci-selenium steps: - checkout - run: name: "Downloading tunnel binary" command: | wget https://s3.amazonaws.com/lambda-tunnel/LT_Linux.zip - run: name: "Extracting tunnel binary" command: | sudo apt-get install unzip unzip LT_Linux.zip - run: name: "Executing tunnel binary" background: true command: | ./LT -user ${LAMBDATEST_EMAIL} -key ${LAMBDATEST_KEY} sleep 40 - run: name: "Setup custom environment variables" command: | echo 'export LT_USERNAME="${LAMBDATEST_USERNAME}"' >> $BASH_ENV - run: name: "Setup custom environment variables" command: | echo 'export LT_ACCESS_KEY="${LAMBDATEST_ACCESS_KEY}"' >> $BASH_ENV - run: # test what branch we're on. name: "Here is the LT_Username : " command: echo ${LT_USERNAME} # Download and cache dependencies # - restore_cache: # keys: # - v1-dependencies-{{ checksum "package.json" }} # fallback to using the latest cache if no exact match is found - run: npm install # - save_cache: # paths: # - node_modules # key: v1-dependencies-{{ checksum "package.json" }} # run tests! - run: node_modules/.bin/nightwatch -e chrome |
Once, the tunnel is successfully set up. You can add the below code to your capabilities for testing internal servers on your network.
1 2 3 |
"desiredCapabilities": { "tunnel":true } |
Parallel Testing is one of the most demanding feature of LambdaTest Selenium Grid. By parallel testing, you can run more than one test case, simultaneously. This means that, Parallel testing would allow you to execute numerous automation test cases altogether. So you execute a single test scenario across different browsers or could run different test scenarios across the same browser but with different browser versions.
To perform automation testing in parallel on Windows use the below command.
1 |
$ node_modules\.bin\nightwatch -e chrome,edge,firefox tests |
To perform automation testing in parallel on macOS/Linux use the below command.
1 |
$ ./node_modules/.bin/nightwatch -e chrome,edge,firefox tests |
Monitor and analyze your test result on the LambdaTest Automation Dashboard.
Deploy your code in a reliable manner at scale using CircleCI integration with LambdaTest, and ensure it looks robust across every browser to provide a seamless user experience to all your visitors. Happy Testing!