0.3.2 • Published 1 year ago

jmeter-xml-generator v0.3.2

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

Built with 🦀Rust

Example

Vue + Axios

You can see example in example-with-vue2

Generate jmeter performance test script with Vue and Axios.

  1. install

    npm install jmeter-xml-generator@0.3.0
  2. enable WebAssembly in Vue2

    // vue.config.js
    const {defineConfig} = require('@vue/cli-service')
    module.exports = defineConfig({
       transpileDependencies: true,
       configureWebpack: {
          experiments: {
             asyncWebAssembly: true,
          }
       }
    })
  3. bind scriptBuilder to Vue.prototype

    import {ScriptBuilder} from "jmeter-xml-generator"
    
    Vue.prototype.scriptBuilder = ScriptBuilder.new()
  4. 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
    })
  5. 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)
0.3.2

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago