mathjax testing

153 views
Skip to first unread message

pa...@rudin.co.uk

unread,
Aug 26, 2012, 7:22:20 AM8/26/12
to mathja...@googlegroups.com
Does anyone please have an example of testing mathjax rendering programmatically?

I'm using mathjax to render some LaTeX in a web page, and I want to write a test to ensure that it's being rendered properly. I can look at the page and it looks fine, but if I grab the source of the page programmatically I just get the raw LaTeX, so I'm not sure how I can check that it's properly rendered.

Peter Krautzberger

unread,
Aug 26, 2012, 12:11:15 PM8/26/12
to mathja...@googlegroups.com
Hm... I'm not sure what you're looking for.

Do you want to check that the TeX is compatible with MathJax (and well-formed)?
Are you looking for webscraping tools in general (like phantomjs http://phantomjs.org/)?
Are you looking for something like Selenium http://seleniumhq.org/?
Something else?

Peter.

Paul Rudin

unread,
Aug 26, 2012, 12:37:30 PM8/26/12
to mathja...@googlegroups.com
I'd like to have a test that can notify me when there's a rendering failure, assuming that the TeX is OK.

Suppose, for example, I changed a template so that the script element referring to the mathjax js was omitted, or incorrect - then the TeX would be present, but not being rendered.

Of course I could make a test for that particular mode of failure, but one can imagine that there might be other things that would cause a rendering problem.
Message has been deleted

Dr. Dayal D. Purohit

unread,
Aug 26, 2012, 1:18:23 PM8/26/12
to mathja...@googlegroups.com
Let me try it again.

If MathJax is loaded, then MathJax != null, otherwise MathJax == null.

d^3p

Dr. Dayal D. Purohit

unread,
Aug 26, 2012, 1:40:09 PM8/26/12
to mathja...@googlegroups.com
If you look at the page and it looks fine, then MathJax is working. If you see raw MathML or TeX code, then definitely not working.

You always will see raw MathML or Tex in the source code.

d^3p

Paul Rudin

unread,
Aug 26, 2012, 6:13:31 PM8/26/12
to mathja...@googlegroups.com
I understand that - but I want to do it as part of a set of automated
tests rather than manually.

Frédéric WANG

unread,
Aug 27, 2012, 9:33:09 AM8/27/12
to mathja...@googlegroups.com
On 27/08/2012 00:13, Paul Rudin wrote:
> I understand that - but I want to do it as part of a set of automated
> tests rather than manually.
d^3p has suggested a way to know whether MathJax is load by testing the
"MathJax" variable. Another things that you might want to know if
whether a Math Processing Error occurred. One way to do that is to add
some javascript code in the errorSettings.message configuration
parameter but note that the next release will have a signal for that
purpose (see https://github.com/mathjax/MathJax/issues/246)

As for how to automate the verification, that seems a bit out of the
scope of MathJax which is just a Javascript library. But using the
javascript tests mentioned above, you could send AJax requests to your
server to indicate a problem. The server would handle the request by,
for example, sending you a warning message by e-mail (depending on what
installation is available to you, of course). Peter also mentioned the
Selenium testing system: http://seleniumhq.org/. This allows to write
program to load Web pages in browsers and control what's happening. The
MathJax test framework (https://github.com/mathjax/MathJax-test) relies
on it and has worked pretty well so far. You could certainly use
Selenium too for your project.

Paul Rudin

unread,
Aug 29, 2012, 1:55:22 AM8/29/12
to mathja...@googlegroups.com
Ok thanks.

It looks like using selenium is probably the way forward. I shall experiment.
Reply all
Reply to author
Forward
0 new messages