Remove jest because it is not needed
Use Testcafé e2e tests for all kinds of frontend testing
This commit is contained in:
@@ -1,30 +0,0 @@
|
|||||||
{
|
|
||||||
"rootDir": "..",
|
|
||||||
"coverageDirectory": "<rootDir>/tests/jest/__coverage__/",
|
|
||||||
"setupFiles": [
|
|
||||||
"<rootDir>/tests/jest/__mocks__/shim.js"
|
|
||||||
],
|
|
||||||
"roots": [
|
|
||||||
"<rootDir>/src/",
|
|
||||||
"<rootDir>/tests/jest/"
|
|
||||||
],
|
|
||||||
"moduleNameMapper": {
|
|
||||||
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/tests/jest/__mocks__/fileMock.js",
|
|
||||||
"\\.(css|scss|less)$": "<rootDir>/tests/jest/__mocks__/styleMock.js"
|
|
||||||
},
|
|
||||||
"moduleFileExtensions": ["ts", "tsx", "js", "jsx"],
|
|
||||||
"transform": {
|
|
||||||
"^.+\\.(ts|tsx)$": "<rootDir>/configs/jest.preprocessor.js"
|
|
||||||
},
|
|
||||||
"transformIgnorePatterns": [
|
|
||||||
"/node_modules/"
|
|
||||||
],
|
|
||||||
"testRegex": "/tests/jest/.*\\.(ts|tsx)$",
|
|
||||||
"moduleDirectories": [
|
|
||||||
"node_modules"
|
|
||||||
],
|
|
||||||
"globals": {
|
|
||||||
"DEVELOPMENT": false,
|
|
||||||
"FAKE_SERVER": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
const tsc = require('typescript');
|
|
||||||
const tsConfig = require('./../tsconfig.json');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
process(src, path) {
|
|
||||||
const isTs = path.endsWith('.ts');
|
|
||||||
const isTsx = path.endsWith('.tsx');
|
|
||||||
const isTypescriptFile = (isTs || isTsx);
|
|
||||||
|
|
||||||
if ( isTypescriptFile ) {
|
|
||||||
src = tsc.transpileModule(
|
|
||||||
src,
|
|
||||||
{
|
|
||||||
compilerOptions: tsConfig.compilerOptions,
|
|
||||||
fileName: path
|
|
||||||
}
|
|
||||||
).outputText;
|
|
||||||
|
|
||||||
// update the path so babel can try and process the output
|
|
||||||
path = path.substr(0, path.lastIndexOf('.')) + (isTs ? '.js' : '.jsx') || path;
|
|
||||||
}
|
|
||||||
|
|
||||||
return src;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
Generated
+111
@@ -8234,6 +8234,111 @@
|
|||||||
"integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=",
|
"integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"husky": {
|
||||||
|
"version": "1.0.0-rc.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/husky/-/husky-1.0.0-rc.9.tgz",
|
||||||
|
"integrity": "sha512-iGGRXcpwl3qGysa73KAtiZWN/YuQVqwgVsPR0UihVasfIsWaAbOfAsswsGmBhKivGtDCdOiLJPTvEZfGJWiCVw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"cosmiconfig": "^5.0.2",
|
||||||
|
"execa": "^0.9.0",
|
||||||
|
"find-up": "^2.1.0",
|
||||||
|
"get-stdin": "^6.0.0",
|
||||||
|
"is-ci": "^1.1.0",
|
||||||
|
"pkg-dir": "^2.0.0",
|
||||||
|
"read-pkg": "^3.0.0",
|
||||||
|
"run-node": "^1.0.0",
|
||||||
|
"slash": "^2.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"cosmiconfig": {
|
||||||
|
"version": "5.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.0.5.tgz",
|
||||||
|
"integrity": "sha512-94j37OtvxS5w7qr7Ta6dt67tWdnOxigBVN4VnSxNXFez9o18PGQ0D33SchKP17r9LAcWVTYV72G6vDayAUBFIg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"is-directory": "^0.3.1",
|
||||||
|
"js-yaml": "^3.9.0",
|
||||||
|
"parse-json": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"execa": {
|
||||||
|
"version": "0.9.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/execa/-/execa-0.9.0.tgz",
|
||||||
|
"integrity": "sha512-BbUMBiX4hqiHZUA5+JujIjNb6TyAlp2D5KLheMjMluwOuzcnylDL4AxZYLLn1n2AGB49eSWwyKvvEQoRpnAtmA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"cross-spawn": "^5.0.1",
|
||||||
|
"get-stream": "^3.0.0",
|
||||||
|
"is-stream": "^1.1.0",
|
||||||
|
"npm-run-path": "^2.0.0",
|
||||||
|
"p-finally": "^1.0.0",
|
||||||
|
"signal-exit": "^3.0.0",
|
||||||
|
"strip-eof": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"get-stdin": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz",
|
||||||
|
"integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"load-json-file": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz",
|
||||||
|
"integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"graceful-fs": "^4.1.2",
|
||||||
|
"parse-json": "^4.0.0",
|
||||||
|
"pify": "^3.0.0",
|
||||||
|
"strip-bom": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"parse-json": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz",
|
||||||
|
"integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"error-ex": "^1.3.1",
|
||||||
|
"json-parse-better-errors": "^1.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"path-type": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"pify": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"read-pkg": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz",
|
||||||
|
"integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"load-json-file": "^4.0.0",
|
||||||
|
"normalize-package-data": "^2.3.2",
|
||||||
|
"path-type": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"slash": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"strip-bom": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
|
||||||
|
"integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"iconv-lite": {
|
"iconv-lite": {
|
||||||
"version": "0.4.19",
|
"version": "0.4.19",
|
||||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz",
|
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz",
|
||||||
@@ -16426,6 +16531,12 @@
|
|||||||
"is-promise": "^2.1.0"
|
"is-promise": "^2.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"run-node": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/run-node/-/run-node-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-kc120TBlQ3mih1LSzdAJXo4xn/GWS2ec0l3S+syHDXP9uRr0JAT8Qd3mdMuyjqCzeZktgP3try92cEgf9Nks8A==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"run-queue": {
|
"run-queue": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz",
|
||||||
|
|||||||
+7
-4
@@ -23,16 +23,19 @@
|
|||||||
"lint:sass": "stylelint ./src/**/**/*.scss ./src/**/*.scss ./src/*.scss",
|
"lint:sass": "stylelint ./src/**/**/*.scss ./src/**/*.scss ./src/*.scss",
|
||||||
"start": "npm run start-dev",
|
"start": "npm run start-dev",
|
||||||
"start-dev": "webpack-dev-server --config=configs/webpack/dev.js",
|
"start-dev": "webpack-dev-server --config=configs/webpack/dev.js",
|
||||||
"test": "npm-run-all test:unit test:e2e",
|
|
||||||
"serve": "node express.js",
|
"serve": "node express.js",
|
||||||
"start-prod": "npm run build && npm run serve",
|
"start-prod": "npm run build && npm run serve",
|
||||||
"test:unit": "jest --watch --coverage --config=configs/jest.json",
|
"test": "npm-run-all lint test:e2e",
|
||||||
"test:e2e": "npm-run-all -s build -p -r serve test:e2e:run",
|
"test:e2e": "npm-run-all -s build -p -r serve test:e2e:run",
|
||||||
"test:e2e:run": "testcafe -S -s 'tests/testcafe/screenshots' --app-init-delay 2000 chrome tests/testcafe",
|
"test:e2e:run": "testcafe -S -s 'tests/testcafe/screenshots' --app-init-delay 2000 chrome tests/testcafe",
|
||||||
"plop": "plop"
|
"plop": "plop"
|
||||||
},
|
},
|
||||||
|
"husky": {
|
||||||
|
"hooks": {
|
||||||
|
"pre-commit": "npm run test"
|
||||||
|
}
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^23.0.0",
|
|
||||||
"@types/node": "^10.3.1",
|
"@types/node": "^10.3.1",
|
||||||
"@types/react": "^16.3.16",
|
"@types/react": "^16.3.16",
|
||||||
"@types/react-dom": "^16.0.6",
|
"@types/react-dom": "^16.0.6",
|
||||||
@@ -46,8 +49,8 @@
|
|||||||
"express": "^4.16.3",
|
"express": "^4.16.3",
|
||||||
"file-loader": "^1.1.11",
|
"file-loader": "^1.1.11",
|
||||||
"html-webpack-plugin": "^3.2.0",
|
"html-webpack-plugin": "^3.2.0",
|
||||||
|
"husky": "^1.0.0-rc.9",
|
||||||
"image-webpack-loader": "^4.3.0",
|
"image-webpack-loader": "^4.3.0",
|
||||||
"jest": "^23.1.0",
|
|
||||||
"node-sass": "^4.9.0",
|
"node-sass": "^4.9.0",
|
||||||
"npm-run-all": "^4.1.3",
|
"npm-run-all": "^4.1.3",
|
||||||
"plop": "^2.0.0",
|
"plop": "^2.0.0",
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
import * as React from 'react';
|
|
||||||
import * as ReactDOM from 'react-dom';
|
|
||||||
import * as TestUtils from 'react-dom/test-utils';
|
|
||||||
import App from '../../src/components/App';
|
|
||||||
|
|
||||||
it('App is rendered', () => {
|
|
||||||
// Render App in the document
|
|
||||||
const appElement: any = TestUtils.renderIntoDocument(
|
|
||||||
<App/>
|
|
||||||
);
|
|
||||||
|
|
||||||
const appNode = ReactDOM.findDOMNode(appElement);
|
|
||||||
|
|
||||||
// Verify text content
|
|
||||||
expect(appNode.textContent).toEqual('Aalto-yliopiston sähköinsinöörikilta!Sähköä, viinaa, naisia.');
|
|
||||||
});
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
module.exports = 'test-file-stub';
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
global.requestAnimationFrame = (callback) => {
|
|
||||||
setTimeout(callback, 0);
|
|
||||||
};
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
module.exports = {};
|
|
||||||
@@ -3,23 +3,35 @@
|
|||||||
* This file is used by TestCafé to run end-to-end tests with chrome against the site.
|
* This file is used by TestCafé to run end-to-end tests with chrome against the site.
|
||||||
* Tests are grouped into fixtures and fixtures into files.
|
* Tests are grouped into fixtures and fixtures into files.
|
||||||
*/
|
*/
|
||||||
import { Selector } from 'testcafe';
|
import { Selector } from "testcafe";
|
||||||
|
|
||||||
fixture`Page renders correctly`.page('http://localhost:3000');
|
fixture`Page renders correctly`.page("http://localhost:3000");
|
||||||
|
|
||||||
test('Paragraph exists and is visible', async t => {
|
test("Paragraph exists and is visible", async t => {
|
||||||
/**
|
/**
|
||||||
* Test if there is a paragraph on the page.
|
* Test if there is a paragraph on the page.
|
||||||
*/
|
*/
|
||||||
const p = Selector('p');
|
const p = Selector("p");
|
||||||
await t.expect(await p.exists && await p.visible);
|
await t.expect(p.exists).ok();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Header contains text "Aalto-yliopiston sähköinsinöörikilta!"', async t => {
|
test("Header contains text \"Aalto-yliopiston sähköinsinöörikilta!\"", async t => {
|
||||||
/**
|
/**
|
||||||
* Test if the header contains the text.
|
* Test if the header contains the text.
|
||||||
*/
|
*/
|
||||||
const header = Selector('h1');
|
const header = Selector("h1");
|
||||||
const text = await header.textContent;
|
const text = await header.textContent;
|
||||||
await t.expect(text.includes('Aalto-yliopiston sähköinsinöörikilta!'));
|
await t.expect(text).contains("Aalto-yliopiston sähköinsinöörikilta!");
|
||||||
|
});
|
||||||
|
|
||||||
|
fixture`Increment button`.page("http://localhost:3000");
|
||||||
|
|
||||||
|
test("Increment button functions correctly", async t => {
|
||||||
|
/**
|
||||||
|
* Test if the increment button works and increments the number inside the button
|
||||||
|
*/
|
||||||
|
const button = Selector("button");
|
||||||
|
await t.expect(button.textContent).contains("0");
|
||||||
|
await t.click(button);
|
||||||
|
await t.expect(button.textContent).contains("1");
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user