Skip to content

Commit

Permalink
Add a new script to include an example module for Cypress tests
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Henneke <[email protected]>
  • Loading branch information
dhenneke committed Aug 10, 2023
1 parent d1f7b08 commit 01017b0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions module_system/BuildConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ export type BuildConfig = {
};

export function readBuildConfig(): BuildConfig {
if (fs.existsSync("./build_config.yaml")) {
return YAML.parse(fs.readFileSync("./build_config.yaml", "utf-8"));
const configFile = process.env.ELEMENT_BUILD_CONFIG ?? "./build_config.yaml";
if (fs.existsSync(configFile)) {
return YAML.parse(fs.readFileSync(configFile, "utf-8"));
}
return {}; // no config
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"start:https": "concurrently --kill-others-on-fail --prefix \"{time} [{name}]\" -n res,element-js \"yarn start:res\" \"yarn start:js --https\"",
"start:res": "yarn build:jitsi && node scripts/copy-res.js -w",
"start:js": "webpack-dev-server --output-filename=bundles/_dev_/[name].js --output-chunk-filename=bundles/_dev_/[name].js -w --mode development --disable-host-check --hot",
"start:e2e": "ELEMENT_BUILD_CONFIG='node_modules/matrix-react-sdk/cypress/example_module/build_config.yaml' yarn start",
"lint": "yarn lint:types && yarn lint:js && yarn lint:style",
"lint:js": "yarn lint:js:src && yarn lint:js:module_system",
"lint:js:src": "eslint --max-warnings 0 src test && prettier --check .",
Expand Down
5 changes: 5 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ module.exports = (env, argv) => {
// probably be removed.
if (f.includes("@vector-im/compound-web")) return true;

// In Cypress we define an example module to test the Module API.
// This is written in typescript and directly imported, so we need
// to apply babel to it to compile it.
if (f.includes("example_module")) return true;

// but we can't run all of our dependencies through babel (many of them still
// use module.exports which breaks if babel injects an 'include' for its
// polyfills: probably fixable but babeling all our dependencies is probably
Expand Down

0 comments on commit 01017b0

Please sign in to comment.