Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

chore: add TS support and remove hardcoded values from visual tests config #817

Merged
merged 12 commits into from
Feb 1, 2019
Merged

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Dropdown, Button, List } from '../../../../../../src'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { Dropdown, Button, List } from '../../../../../../src'
import { Dropdown, Button, List } from '@stardust-ui/react'

Can we use just this?

If it requires tsconfig, this should work:

require("ts-node").register({
  project: "build/tsconfig.common.json",
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me check..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately, this doesn't help - but, actually, I would also expect that it should. Will take another look tomorrow, thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taking this as a general problem (import expressions like this one could be met quite often in the code), will clean up this stuff in the dedicated PR. Currently wasn't able to come up with resolution, but will spend additional time today


const steps = [
steps => steps.click(`.${Dropdown.className} .${Button.className}`).snapshot('Shows list'),
steps => steps.click(`.${List.className} li:nth-child(3)`).snapshot('Selects an element'),
steps =>
steps
.click(`.${Dropdown.className} .${Button.className}`)
.snapshot('Opens with selected element highlighted'),
steps => steps.hover(`.${List.className} li:nth-child(2)`).snapshot('Highlights another element'),
]

export default steps
39 changes: 27 additions & 12 deletions screener.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
require('ts-node').register()

const _ = require('lodash')
const glob = require('glob')
const path = require('path')
const fs = require('fs')

const { default: config } = require('./config')
const Steps = require('screener-runner/src/steps')

const SCREENER_HOST_URL = `${config.server_host}:${config.server_port}`

// https://github.com/screener-io/screener-runner
const screenerConfig = {
projectRepo: 'stardust-ui/react',

apiKey: process.env.SCREENER_API_KEY,

tunnel: {
host: 'localhost:8080',
host: `${SCREENER_HOST_URL}`,
gzip: true, // gzip compress all content being served from tunnel host
cache: true, // sets cache-control header for all content being served from tunnel host. Must be used with gzip option
},
Expand All @@ -31,26 +37,35 @@ const screenerConfig = {
states: glob
.sync('docs/src/examples/**/*.tsx', { ignore: ['**/index.tsx', '**/*.knobs.tsx'] })
.reduce((states, examplePath) => {
const { name: nameWithoutExtension, base: nameWithExtension, dir } = path.parse(examplePath)
const rtl = nameWithExtension.endsWith('.rtl.tsx')
const url = `http://localhost:8080/maximize/${_.kebabCase(nameWithoutExtension)}/${rtl}`
const {
name: exampleNameWithoutExtension,
base: exampleNameWithExtension,
dir: exampleDir,
} = path.parse(examplePath)

const rtl = exampleNameWithExtension.endsWith('.rtl.tsx')
const exampleUrl = _.kebabCase(exampleNameWithoutExtension)

states.push({
url,
name: nameWithExtension,
// https://github.com/screener-io/screener-runner
steps: fs.existsSync(`${dir}/${nameWithoutExtension}.steps.js`)
? getSteps(dir, nameWithoutExtension).end()
: undefined,
url: `http://${SCREENER_HOST_URL}/maximize/${exampleUrl}/${rtl}`,
name: exampleNameWithExtension,

// https://www.npmjs.com/package/screener-runner#testing-interactions
steps: getSteps(exampleDir, exampleNameWithoutExtension),
})

return states
}, []),
}

function getSteps(dir, nameWithoutExtension) {
const stepTests = require(`./${dir}/${nameWithoutExtension}.steps`)
return stepTests.reduce((stepsAcc, steps) => steps(stepsAcc), new Steps())
const stepsSpecModulePath = `${dir}/${nameWithoutExtension}.steps.ts`

return fs.existsSync(stepsSpecModulePath)
? require(`./${dir}/${nameWithoutExtension}.steps`)
.default.reduce((stepsAcc, steps) => steps(stepsAcc), new Steps())
.end()
: undefined
}

if (process.env.CI) {
Expand Down