jmeter-xml-generator
v0.3.2
Published
<div style="display:flex;flex-direction: column;align-items: center">
Downloads
1
Readme
Built with 🦀Rust
Example
Vue + Axios
You can see example in example-with-vue2
Generate jmeter performance test script with Vue and Axios.
install
npm install [email protected]
enable WebAssembly in Vue2
// vue.config.js const {defineConfig} = require('@vue/cli-service') module.exports = defineConfig({ transpileDependencies: true, configureWebpack: { experiments: { asyncWebAssembly: true, } } })
bind scriptBuilder to Vue.prototype
import {ScriptBuilder} from "jmeter-xml-generator" Vue.prototype.scriptBuilder = ScriptBuilder.new()
add middleware to axios
const instance = axios.create({ baseURL: 'http://localhost:26005/' }) instance.interceptors.request.use(function (config) { const heads = {"Content-Type": config.headers["Content-Type"]} const requestArg = JSON.stringify({ baseUrl: config.baseURL, url: config.url, method: config.method, heads, params: config.params, data: config.data, }) Vue.prototype.scriptBuilder.add_axios_request(requestArg) return config })
download script
const result = Vue.prototype.scriptBuilder.build() let blob = new Blob([result], {type: "application/xml"}) let blobUrl = URL.createObjectURL(blob) let linkDOM = document.createElement("a") linkDOM.style.display = "none" linkDOM.href = blobUrl linkDOM.setAttribute("download", "test script " + Date.now() + ".jmx") document.body.appendChild(linkDOM) linkDOM.click() document.body.removeChild(linkDOM) URL.revokeObjectURL(blobUrl)