Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests #88

Merged
merged 9 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ node_modules/
.cache/

.rts2_cache_*

.vscode
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sudo: required

services:
- docker

script:
- docker build -t comlink .
- docker run --rm -v `pwd`:/usr/src comlink
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM selenium/node-chrome:latest@sha256:31be7ba7ebe6db9f9b266c10fc5f6fce7568791a6ade91b6b6d20a29a988ef5b

USER root

RUN apt-get update -qqy \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
&& rm /bin/sh && ln -s /bin/bash /bin/sh \
&& chown seluser /usr/local

ENV NVM_DIR /usr/local/nvm
RUN wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash \
&& source $NVM_DIR/nvm.sh \
&& nvm install v11

ENV CHROME_BIN /opt/google/chrome/chrome
ENV INSIDE_DOCKER=1

WORKDIR /usr/src
ENTRYPOINT source $NVM_DIR/nvm.sh && npm i && npm run test
72 changes: 72 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
module.exports = function (config) {
config.set({
frameworks: ["mocha", "chai", "detectBrowsers"],
files: [{ pattern: "test/*.test.js" }],
preprocessors: {
"test/*.test.js": ["webpack"], //preprocess with webpack
},
reporters: ["dots"], //report results in this format
webpack: {
devtool: "inline-source-map", //just do inline source maps instead of the default
module: {
rules: [
{
test: /test\.js$/,
use: {
loader: "babel-loader",
options: {
presets: [
[
"@babel/preset-env",
{
targets: {
esmodules: true,
},
},
],
],
plugins: [
"@babel/plugin-transform-react-jsx",
"@babel/plugin-proposal-optional-chaining",
],
},
},
},
],
},
},
reporters: ["progress"],
singleRun: true,
port: 9876, // Karma web server port
colors: true,
logLevel: config.LOG_INFO,
detectBrowsers: {
enabled: true,
usePhantomJS: false,
preferHeadless: true,
postDetection: (availableBrowsers) => {
if (process.env.INSIDE_DOCKER) {
return ["DockerChrome"];
} else if (process.env.CHROME_ONLY) {
return ["ChromeHeadless"];
} else {
// Filtering SafariTechPreview because I am having
// local issues and I have no idea how to fix them.
// I know that’s not a good reason to disable tests,
// but Safari TP is relatively unimportant.
return availableBrowsers.filter(
(browser) => browser !== "SafariTechPreview"
);
}
},
},
customLaunchers: {
DockerChrome: {
base: "ChromeHeadless",
flags: ["--no-sandbox"],
},
},
autoWatch: false,
concurrency: Infinity,
});
};
Loading