Zotero translator does not work with testCases
I'm trying to write a web translator, which is pretty much functional. However, I'm experiencing a problem with adding var testCases.
Both detectWeb() and doWeb() work on Scaffold (on FF55 and Zotero 4) and I can import an item through Zotero icon successfully as long as there is no testCases variable.
However, once I add a code for var testCases into the Tests pane of Scaffold, as shown here (https://www.zotero.org/support/dev/translators/testing), then Zotero button does not show the translator I'm developing, even though it still returns a correct item on Scaffold. I've also noticed that adding testCase code with item data copied from Scaffold output is not reflected by the Testing pane; nothing shows up in this pane.
Further, although I can save the testCase code by Scaffold's Save button, when I load the saved translator by Load button, the Tests pane is empty.
Apparently, something is wrong about testCases, but I'm not sure what. Your suggestions will be appreciated.
translator code
https://gist.github.com/kouichi-c-nakamura/3a0bf4365beb9156e888330e89507d21
Cheers,
Kouichi
Both detectWeb() and doWeb() work on Scaffold (on FF55 and Zotero 4) and I can import an item through Zotero icon successfully as long as there is no testCases variable.
However, once I add a code for var testCases into the Tests pane of Scaffold, as shown here (https://www.zotero.org/support/dev/translators/testing), then Zotero button does not show the translator I'm developing, even though it still returns a correct item on Scaffold. I've also noticed that adding testCase code with item data copied from Scaffold output is not reflected by the Testing pane; nothing shows up in this pane.
Further, although I can save the testCase code by Scaffold's Save button, when I load the saved translator by Load button, the Tests pane is empty.
Apparently, something is wrong about testCases, but I'm not sure what. Your suggestions will be appreciated.
translator code
https://gist.github.com/kouichi-c-nakamura/3a0bf4365beb9156e888330e89507d21
Cheers,
Kouichi
I've noticed that, when loading, Scaffold shows error message "Exception parsing JSON", so JSON data format is the problem. I figured that lots of commas at the end of a line are missing from Scaffold output as JSON format. Now I checked the grammar of the block /** BEGIN TEST CASES **/ with an editor.
However, updated version still shows "Exception parsing JSON" when loading and Tests pane is still empty.
https://gist.github.com/kouichi-c-nakamura/7fddbe1003fea885310487ccf1048f0f
There's an illegal comma in the test JSON, (in line 276: https://gist.github.com/kouichi-c-nakamura/7fddbe1003fea885310487ccf1048f0f#file-sfn-abstract-js-L276 ) but the test suite literally should be incapable of writing invalid JSON, so it seems like you're doing something different from how it's intended.
But why instruction on the official site (https://www.zotero.org/support/dev/translators/testing) is not good enough??
As it turned out, from the same reason why I cannot implement attachments or mulitiple, testCases fail in the Testing pane ("Run" button issues an error that suggests that page content is not loaded).
There's a chance that it may just be taking extra time to load the content. But ZU.processDocuments or ZU.HTTP.processDocuments does not have delaying option......
https://groups.google.com/d/msg/zotero-dev/EnC5teZkSP8/MZ-ezcZMCAAJ
(For future reference, it's better to post these questions to zotero-dev.)