Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for non-JSON image mocks #913

Open
etpinard opened this issue Sep 7, 2016 · 3 comments
Open

Add support for non-JSON image mocks #913

etpinard opened this issue Sep 7, 2016 · 3 comments

Comments

@etpinard
Copy link
Contributor

etpinard commented Sep 7, 2016

PR #850 made us realised that not all plotly.js features are JSON serializable e.g. Float32Array.

Possible solution: we could try to make the image tests routine and the test dashboard accept js files as mock. These js files would generate { data: [], layout: {} } object.

For example,

// in test/image/mocks/float32array.js

module.exports = function() {
  return {
    data: [{
      xy: new Float32Array([1,2,3,4])
    }]
  }
}
@etpinard
Copy link
Contributor Author

Ping @plotly/plotly_js

Might be a good time to tackle this.

@etpinard
Copy link
Contributor Author

etpinard commented Jul 25, 2019

So, I propose:

  • keep the test/image/mocks/ folder intact. A lot of things (e.g. https://rreusser.github.io/plotly-mock-viewer/) are looking into this folder from http://raw.githubusercontent.com/ to do stuff with the JSON mocks.
  • add a test/image/mock-generators/ folder with js files such that: test/image/mock-generators/some-mock.js would correspond to test/image/mocks/some-mock.json

then

  • before npm run test-image, npm run baseline and npm run test-export we would run these test/image/mock-generators/ scripts in Node.js to then update text/image/mocks/ before generating baselines or running the image tests.

Now, we would still need to keep the output of test/image/mock-generators/ pure JSON (e.g. no TypedArrays). Down the road (when / if we switch to orca to run our image tests), we could try to generate the mocks in the front-end by adding a new orca renderer.

We would also need to find a way to keep test/image/mock-generators/ and test/image/mocks/ in-sync. I can think of two solutions:

  • PRs that add files to test/image/mock-generators/ do not add the corresponding files in test/image/mocks/. test/image/mocks/ would be added during version commits.

    • 👍 no extra step (that could be sometimes forgotten) for developers
    • 👎 new test/image/mocks/ JSON files are not available until next plotly.js version
  • PRs that add files to test/image/mock-generators/, must add the corresponding files in test/image/mocks/

    • 👍 test/image/mocks/ JSON files are always available
    • 👎 we would have to add extra machinery (probably a syntax test) to make sure test/image/mock-generators/ and test/image/mocks/ are in-sync

Thoughts?

@archmoj
Copy link
Contributor

archmoj commented Jul 25, 2019

I'd vote for the second solution noting that few jasmine tests are dependent on the mocks; and one may want to run them in parallel.

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

No branches or pull requests

2 participants