Skip to content

Instantly share code, notes, and snippets.

@tejima
Created March 2, 2015 06:06
Show Gist options
  • Save tejima/fb16e8500d07d62c3d17 to your computer and use it in GitHub Desktop.
Save tejima/fb16e8500d07d62c3d17 to your computer and use it in GitHub Desktop.
nightwatch 画面テストでJavascriptエラーを検知する方法

http://daipresents.com/2012/post-4906/

HTML側に

<script type="text/javascript">
window.jsErrors = [];
window.onerror = function(errorMessage) {
  window.jsErrors[window.jsErrors.length] = errorMessage;
}
</script>

nightwatch側に

        client
            .url("https://pc3.parseapp.com/app.html")
            .execute(function(data) {
                return window.jsErrors;
            }, [null], function(result) {
                client.assert.equal(result.value.length, 0, "num script error should be 0");
            });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment