Promise based HTTP client for the browser and node.js
// Automation Testing console.log("=== Automation Testing ==="); const axios = require('axios'); axios.post('http://localhost/latex2svg', { latex: '$$\frac{1}{2}$$' }).then(res => { console.log(`Response.data : `, res.data); });
HTTP Requester, even support GraphQL for automation tests. Text based, fast and portable.
https://requester.org/#documentationindex.html
function latex2svg(latex) { fetch('/.netlify/functions/latex2svg', { method: 'POST', body: JSON.stringify(latex), headers: new Headers({ 'Content-Type': 'application/json' }), mode: 'cors' // no-cors, cors, *same-origin }).then(response => { return response.json(); }).then(json => { container = document.getElementById('svg_container'); container.innerHTML = json.svg; }).catch( error => { console.log("Something Wrong"); });; } latex2svg({ "latex" : '\$\$\\LaTeX \\frac{1}{3}\$\$'});mode: no-cors
no-cors is required to cross origin access when tring to load my service directly in your own html.
Free serverless web service
npm run netlify-lambda build functions
exports.handler = function(event, context, callback) { // event.body // context for dev/prod environment info callback(null, { statusCode: 200, body: {svg: "<svg></svg>"} }); }
[build] function = "lambda" // the compiled path of lambda functions
nodemon app.js or npm run start
axios to send the test requests after launch automatically.
It's possible to write the automation tests with assert too.
Sublime Text with Requester(pacakge)
## localhost node app.js test requests.post('http://localhost/.netlify/functions/latex2svg', json = {"latex": "$$\frac{}$$"}) ## localhost netlify-lambda serve functions test. requests.post('http://localhost:9000/.netlify/functions/latex2svg', json = {"latex": "$$\\frac{1}{6}$$"}) ## netlify-lambda function server test requests.post('https://rintaroutw-latex2svg.netlify.com/.netlify/functions/latex2svg', json = {"latex": "$$\\frac{1}{6}$$"})