mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-19 08:31:35 +03:00
* feat(tauri.js) add API endpoint proxy * feat(tauri.js) always resolve/reject proxy promise * chore(proxy) wait for onTauriInit to start direct proxy to window.tauri * feat(tests) add project for initial e2e test * chore(tauri) remove whitespaces on runner.rs * chore(test): remove updater.rs * feat(tests) move e2e test to tauri.js/test/jest thanks to @laegel for the awesome work moving the test code to jest * feat(tests) prepare build for modes tests * fix(tests) properly run build tests * feat(tests) add dev e2e test * fix(tests) cleanup * chore(tests) move e2e test from express to http.createServer * chore(tauri.js) husky back to 4.0.10 * chore(tests) custom transformer to export with default * chore(tests) use jest mapping instead of relative paths * chore(tests) move dev e2e test to http.createServer * chore(tests) move dev/build e2e test to tes.each instead of for loop * chore(tauri.js) add comment to non-webpack-require.ts * chore(tests) change test.each to it.each * chore(tests) adjust it.each message signature * fix(tests) adjust to properly run on initial build * fix(tests) properly cleanup * fix(tests) wait server.close to reject test * fix(tests) wait server.close to resolve test * fix(actions) install webkit2gtk-4.0 on test-tauri-js-cli * fix(ci) install tauri-cli on test-tauri-js-cli * fix(tauri.js) lint errors Co-authored-by: Lucas Nogueira <lucas@quasar.dev> Co-authored-by: nothingismagick <denjell@sfosc.org>
64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
const path = require('path')
|
|
const process = require('process')
|
|
|
|
const appDir = path.resolve(__dirname, '../fixtures/app')
|
|
const tauriDir = path.join(appDir, 'src-tauri')
|
|
|
|
module.exports.appDir = appDir
|
|
module.exports.distDir = path.join(appDir, 'dist')
|
|
|
|
import * as appPaths from '../../../src/helpers/app-paths'
|
|
|
|
module.exports.initJest = () => {
|
|
jest.mock('helpers/non-webpack-require', () => {
|
|
return path => {
|
|
const value = require('fs').readFileSync(path).toString()
|
|
if (path.endsWith('.json')) {
|
|
return JSON.parse(value)
|
|
}
|
|
return value
|
|
}
|
|
})
|
|
appPaths.appDir = appDir
|
|
appPaths.tauriDir = tauriDir
|
|
jest.spyOn(appPaths.resolve, 'app').mockImplementation(dir => path.resolve(appDir, dir))
|
|
jest.spyOn(appPaths.resolve, 'tauri').mockImplementation(dir => path.resolve(tauriDir, dir))
|
|
jest.spyOn(process, 'exit').mockImplementation(() => {})
|
|
}
|
|
|
|
module.exports.startServer = (onReply) => {
|
|
const http = require('http')
|
|
const app = http.createServer((req, res) => {
|
|
// Set CORS headers
|
|
res.setHeader('Access-Control-Allow-Origin', '*')
|
|
res.setHeader('Access-Control-Request-Method', '*')
|
|
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET')
|
|
res.setHeader('Access-Control-Allow-Headers', '*')
|
|
|
|
if (req.method === 'OPTIONS') {
|
|
res.writeHead(200)
|
|
res.end()
|
|
return
|
|
}
|
|
|
|
if (req.method === 'POST') {
|
|
if (req.url === '/reply') {
|
|
let body = ''
|
|
req.on('data', chunk => {
|
|
body += chunk.toString()
|
|
})
|
|
req.on('end', () => {
|
|
expect(JSON.parse(body)).toStrictEqual({
|
|
msg: 'TEST'
|
|
})
|
|
server.close(onReply)
|
|
})
|
|
}
|
|
}
|
|
})
|
|
|
|
const port = 7000
|
|
const server = app.listen(port)
|
|
return server
|
|
}
|