Conversation
package.json
Outdated
| "test:unit": "jest --config jest.config.js --no-watchman", | ||
| "test:ci": "npm run test:unit -- --runInBand", | ||
| "test:e2e": "skpm-test", | ||
| "test:e2e:examples": "npm run build --prefix __tests__/examples/", |
There was a problem hiding this comment.
Maybe npm run render:once --prefix ... is better for now? Later on this should probably run with test:e2e, together with the other e2e tests.
…act-sketchapp into dev/e2e-example-tests
|
@mathieudutour I've got e2e tests working again, and have the e2e example tests working now too 🙂. Took a while to debug it: I found that importing There's a bit of clean up to do before a merge, but would be ideal to have a review first. I'm using packages that are installed in I'm still running into #515 (in test runner, and in a normal PASS basic
PASS render-context
PASS render-in-wrapped-object
FAIL examples
● examples › should render examples
React SketchApp cannot render into this layer. You may be trying to render into a layer that does not take children. Try rendering into a LayerGroup, Artboard, or Page.
at <anonymous> (../../lib/render.js:23:14)
at <anonymous> (./examples.test.js:72:2)
at <anonymous> (../../node_modules/promise-polyfill/lib/index.js:79:0)
at <anonymous> (../../node_modules/@skpm/timers/timeout.js:18:0)
✕ should render examplesPatching
import * as Svg from './Svg';to import Svg from './Svg';fixes it and gets the example e2e tests to pass (and |
__tests__/skpm/examples.test.js
Outdated
| return sketch.getSelectedDocument() || document; | ||
| } | ||
|
|
||
| const examplePages = [ |
There was a problem hiding this comment.
a lot fo this is duplicated in main.js. Could easily import it from there
| @@ -0,0 +1,14 @@ | |||
| { | |||
There was a problem hiding this comment.
why do you need this file?
There was a problem hiding this comment.
I pulled it from before the TypeScript refactor. I believe @babel/plugin-transform-modules-commonjs is needed for @skpm/test-runner? @skpm/test-runner@0.4.1 has this plugin, but without "noInterop": true.
Without the .babelrc file, the tests give this error:
undefined is not an object (evaluating 'module.exports.tests = __skpm_tests__')| @@ -0,0 +1,24 @@ | |||
| const path = require('path'); | |||
|
|
|||
| const aliasedModules = [ | |||
There was a problem hiding this comment.
could we get this list from the package.json? Just to make sure nothing is missing
| "devDependencies": { | ||
| "@skpm/babel-preset": "^0.2.1", | ||
| "@skpm/test-runner": "^0.4.1", | ||
| "@skpm/test-runner": "^0.3.2", |
There was a problem hiding this comment.
hum that's unfortunate. I'll try to see what's up
| "docs:publish": "npm run docs:clean && npm run docs:build && cd _book && git init && git commit --allow-empty -m 'update book' && git fetch https://github.com/airbnb/react-sketchapp gh-pages && git checkout -b gh-pages && git add . && git commit -am 'update book' && git push https://github.com/airbnb/react-sketchapp gh-pages --force", | ||
| "lint-staged": "lint-staged", | ||
| "prepublishOnly": "npm run clean && npm run test:ci && npm run build", | ||
| "prepublishOnly": "npm run clean && npm run test:ci && npm run install:e2e && npm run build", |
There was a problem hiding this comment.
npm run install:e2e triggers the __tests__/examples postinstall script. Not sure if this should be left in, it'll fail the prepublish script if the examples skpm-build fails, but not sure if it'll work in CI.
| ...config.resolve, | ||
| alias: { | ||
| ...config.resolve.alias, | ||
| 'react-sketchapp': path.resolve(__dirname, '../../lib'), |
There was a problem hiding this comment.
Seems that @skpm/test-runner needs the commonjs build, and doesn't work with the ES build, strange.
This PR introduces a new e2e test folder that runs the code from all examples at once.
To avoid instantiating each folder's npm packages, I'm installing every npm package that is needed for specific examples, and aliasing them with Webpack, e.g.
chroma-js, etc. This does currently mean that apostinstallscript to install the packages in__tests__/examplesis required though.npm run test:e2eappears to be broken since the TypeScript refactor (or later maybe), maybe noncommonjsmodules are being used somewhere. Importingyoga-layout-prebuiltcrashesskpm-test, but that appears to be usingcommonjsthough.So for now, I'm creating a monolithic test example that is added to the test pipeline with
npm run build --prefix __tests__/examples/, and can be manually run in Sketch GUI (orskpm-build --run), or will error out if there is a build breaking issue.This should make it easy to test all examples with a single command.
This PR could be used later on to generate
pngs from all the examples to do a pixel diff test, which would help a lot with the platform bridge refactor, and help out with alignment with React Native, and act as a benchmark for other React renderers to test implementation 🚀. This is something I noticed was mentioned in the React Primitives RFC (using Happo for cross-platform visual regression testing).TODO
skpm-testand use that instead for the examples testfixes #363