Skip to content

Commit 3c951bc

Browse files
authored
Testcafe demos tests: use ts instead of js (DevExpress#31206)
1 parent ac33c9f commit 3c951bc

File tree

88 files changed

+51
-30
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+51
-30
lines changed

apps/demos/.testcaferc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"src": [
3-
"./testing/**/*.test.js"
3+
"./testing/**/*.test.ts"
44
],
55
"screenshots": {
66
"path": "./",

apps/demos/babel.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
module.exports = {
2-
presets: [['@babel/preset-env', { targets: { node: 'current' } }]],
2+
presets: [
3+
['@babel/preset-env', { targets: { node: 'current' } }],
4+
'@babel/preset-typescript',
5+
],
36
};

apps/demos/eslint.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,11 +460,11 @@ export default [
460460
...compat.extends('devextreme/testcafe').map(config => ({
461461
...config,
462462
rules: changeRulesToStylistic(config.rules || {}),
463-
files: ['testing/**/*.js', 'utils/visual-tests/**/*.*'],
463+
files: ['testing/**/*.{js,ts}', 'utils/visual-tests/**/*.*'],
464464
})),
465465

466466
{
467-
files: ['testing/**/*.js'],
467+
files: ['testing/**/*.{js,ts}'],
468468
languageOptions: {
469469
globals: {
470470
testUtils: true,

apps/demos/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@
168168
"lint-css": "stylelint **/*.{css,vue}",
169169
"lint-non-demos": "pnpx nx run-many -t lint-js lint-css lint-html -p devextreme-demos",
170170
"lint": "pnpm run lint-non-demos && pnpm run lint-demos",
171-
"test-testcafe": "node utils/visual-tests/testcafe-runner.mjs",
172-
"test-testcafe:accessibility": "cross-env STRATEGY=accessibility CONSTEL=jquery node utils/visual-tests/testcafe-runner.mjs",
171+
"test-testcafe": "ts-node utils/visual-tests/testcafe-runner.ts",
172+
"test-testcafe:accessibility": "cross-env STRATEGY=accessibility CONSTEL=jquery node utils/visual-tests/testcafe-runner.ts",
173173
"fix-lint": "prettier --write . && eslint --fix . && stylelint **/*.{css,vue} --fix",
174174
"prettier": "prettier",
175175
"build-bundles": "gulp bundles",
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ FRAMEWORKS.forEach((approach) => {
6565
t.ctx.watchDogHandle = setTimeout(() => { throw new Error('test timeout exceeded'); }, 3 * 60 * 1000);
6666
await t.resizeWindow(1000, 800);
6767
})
68-
.afterEach((t) => clearTimeout(t.ctx.watchDogHandle))
68+
.afterEach(async (t) => clearTimeout(t.ctx.watchDogHandle))
6969
.clientScripts([
7070
{ module: 'mockdate' },
7171
{ module: 'axe-core/axe.min.js' },
72+
// @ts-expect-error Type 'string' is not assignable to type 'ClientScript'
7273
join(__dirname, '../utils/visual-tests/inject/test-utils.js'),
73-
{ content: injectStyle(globalReadFrom(__dirname, '../utils/visual-tests/inject/test-styles.css')) },
74+
{ content: injectStyle(globalReadFrom(__dirname, '../utils/visual-tests/inject/test-styles.css', (x) => x)) },
7475
{
7576
content: `
7677
window.addEventListener('error', function (e) {
@@ -93,8 +94,8 @@ FRAMEWORKS.forEach((approach) => {
9394
const testName = `${widgetName}-${demoName}`;
9495

9596
const clientScriptSource = readFrom('../client-script.js', (x) => [{ content: x }]) || [];
96-
const testCodeSource = readFrom('../test-code.js');
97-
const testCafeCodeSource = readFrom('../testcafe-test-code.js');
97+
const testCodeSource = readFrom('../test-code.js', (x) => x);
98+
const testCafeCodeSource = readFrom('../testcafe-test-code.js', (x) => x);
9899
const visualTestSettings = readFrom('../visualtestrc.json', (x) => JSON.parse(x));
99100
const visualTestStyles = readFrom('../test-styles.css', (x) => injectStyle(x));
100101

apps/demos/testing/widgets/accordion/Accordion.test.js renamed to apps/demos/testing/widgets/accordion/Accordion.test.ts

File renamed without changes.
File renamed without changes.

apps/demos/testing/widgets/charts/CustomAnnotationsDrag.test.js renamed to apps/demos/testing/widgets/charts/CustomAnnotationsDrag.test.ts

File renamed without changes.

apps/demos/testing/widgets/charts/CustomLegendMarkers.test.js renamed to apps/demos/testing/widgets/charts/CustomLegendMarkers.test.ts

File renamed without changes.

apps/demos/testing/widgets/charts/Export.test.js renamed to apps/demos/testing/widgets/charts/Export.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ fixture('Charts.Export')
66
ctx.initialWindowSize = [900, 600];
77
});
88

9+
declare global {
10+
interface Window {
11+
originalCreateObjectURL: (obj: Blob | MediaSource) => string;
12+
testedValue: string;
13+
}
14+
}
15+
916
runManualTest('Charts', 'ExportCustomMarkup', (test) => {
1017
test('Export', async (t) => {
1118
let isFileCreateForDownload = false;
@@ -14,7 +21,9 @@ runManualTest('Charts', 'ExportCustomMarkup', (test) => {
1421
window.originalCreateObjectURL = URL.createObjectURL;
1522
window.testedValue = '';
1623

24+
// @ts-expect-error wrong type
1725
URL.createObjectURL = (blob) => {
26+
// @ts-expect-error Blob.type is not typed
1827
window.testedValue = blob.type;
1928

2029
return Promise.reject();

0 commit comments

Comments
 (0)