diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-05-03 19:47:39 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-05-16 00:55:02 +0200 |
commit | d2aa484b600dc0d122bb994b9bb29504ffe4cf12 (patch) | |
tree | 1d3e38fdb22f7afe02f1ebcf4b07734761970985 /scripts | |
parent | refactor: config file saving and debugging (diff) | |
download | sophie-d2aa484b600dc0d122bb994b9bb29504ffe4cf12.tar.gz sophie-d2aa484b600dc0d122bb994b9bb29504ffe4cf12.tar.zst sophie-d2aa484b600dc0d122bb994b9bb29504ffe4cf12.zip |
build: integration testing support
Run integration tests in an electron environment for the main process.
Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/electronJest.cjs | 12 | ||||
-rw-r--r-- | scripts/watch.js | 5 |
2 files changed, 16 insertions, 1 deletions
diff --git a/scripts/electronJest.cjs b/scripts/electronJest.cjs new file mode 100644 index 0000000..a7b7986 --- /dev/null +++ b/scripts/electronJest.cjs | |||
@@ -0,0 +1,12 @@ | |||
1 | const { app } = require('electron'); | ||
2 | |||
3 | if (process.env.DISABLE_GPU === 'true') { | ||
4 | app.disableHardwareAcceleration(); | ||
5 | } | ||
6 | |||
7 | app.on('window-all-closed', () => { | ||
8 | // Handle event to avoid exiting the application in watch mode. | ||
9 | }); | ||
10 | |||
11 | // @ts-expect-error -- `jest-cli` has no typescript declaration. | ||
12 | require('jest-cli/bin/jest'); | ||
diff --git a/scripts/watch.js b/scripts/watch.js index 3c3a8fd..eeee6e4 100644 --- a/scripts/watch.js +++ b/scripts/watch.js | |||
@@ -26,6 +26,9 @@ const serviceInjectModule = path.join( | |||
26 | '../packages/service-inject/dist/index.js', | 26 | '../packages/service-inject/dist/index.js', |
27 | ); | 27 | ); |
28 | 28 | ||
29 | /** @type {string} */ | ||
30 | const userDataDir = path.join(thisDir, '../userDataDir/development'); | ||
31 | |||
29 | /** @type {RegExp[]} */ | 32 | /** @type {RegExp[]} */ |
30 | const stderrIgnorePatterns = [ | 33 | const stderrIgnorePatterns = [ |
31 | // warning about devtools extension | 34 | // warning about devtools extension |
@@ -141,7 +144,7 @@ function setupMainPackageWatcher(viteDevServer) { | |||
141 | function spawnProcess() { | 144 | function spawnProcess() { |
142 | childProcess = spawn( | 145 | childProcess = spawn( |
143 | String(electronPath), | 146 | String(electronPath), |
144 | ['.', ...process.argv.slice(2)], | 147 | ['.', `--user-data-dir=${userDataDir}`, ...process.argv.slice(2)], |
145 | { | 148 | { |
146 | stdio: ['inherit', 'inherit', 'pipe'], | 149 | stdio: ['inherit', 'inherit', 'pipe'], |
147 | }, | 150 | }, |