# Running tests

karma.conf.js:

const {
  createDefaultConfig
} = require("@open-wc/testing-karma");
const merge = require("deepmerge");

karma.conf.js:

module.exports = config => {
  config.set(
    merge(
      createDefaultConfig(config),
      createConfigOverride(config)
    )
  );
  return config;
};

karma.conf.js:

const createConfigOverride = config => ({
  files: [
    {
      pattern: config.grep
        ? config.grep
        : "./src/**/*.test.js",
      type: "module"
    }
  ],

  esm: {
    nodeResolve: true
  }
});

tests/config/jest.config.js:

setupFiles: [
  "<rootDir>/node_modules/babel-polyfill/dist/polyfill.js",
  "<rootDir>/node_modules/document-register-element/build/document-register-element.node.js"
],

tests/config/jest.config.js:

  testEnvironment: "jest-environment-jsdom-sixteen",

tests/config/jest.config.js:

transform: {
  "^.+\\.(mjs|jsx|js)$": [
    "babel-jest",
    { configFile: "./tests/config/babel-jest.config.js" }
  ]
}

tests/config/babel-jest.config.js:

module.exports = {
  presets: [["@babel/preset-env", { modules: "commonjs" }]]
};

tests/config/jest-puppeteer.config.js:

module.exports = {
  preset: "jest-puppeteer",
  rootDir: "../..",
  testMatch: ["**/tests/e2e/**/?(*.)jest.[tj]s?(x)"],
  globals: {
    ORIGIN: "http://localhost:8000"
  }
};