Skip to content

Commit

Permalink
[test] Smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Nov 6, 2020
1 parent 983d7aa commit a21faff
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 21 deletions.
9 changes: 9 additions & 0 deletions packages/grid/x-grid/src/XGrid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ describe('<XGrid />', () => {
container.firstChild.firstChild.firstChild,
);
});

it('should not fail after scheduled tasks are run', async () => {
render(
<div style={{ width: 300, height: 300 }}>
<XGrid {...defaultProps} />
</div>,
);
await sleep(0);
});
});

describe('keyboard', () => {
Expand Down
1 change: 1 addition & 0 deletions test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module.exports = function setKarmaConfig(config) {
'process.env': {
NODE_ENV: JSON.stringify('test'),
CI: JSON.stringify(process.env.CI),
KARMA: JSON.stringify(true),
},
}),
],
Expand Down
52 changes: 50 additions & 2 deletions test/karma.tests.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,55 @@
/* eslint-env mocha */
import './utils/init';
import consoleError from './utils/consoleError';
import { createMochaHooks } from '@material-ui/monorepo/test/utils/mochaHooks';

consoleError();
const mochaHooks = createMochaHooks(window.Mocha);

before(function beforeAllHook() {
mochaHooks.beforeAll.forEach((mochaHook) => {
mochaHook.call(this);
});
});

after(function afterAllHook() {
mochaHooks.afterAll.forEach((mochaHook) => {
mochaHook.call(this);
});
});

beforeEach(function beforeEachHook() {
mochaHooks.beforeEach.forEach((mochaHook) => {
mochaHook.call(this);
});
});

afterEach(function afterEachHook() {
mochaHooks.afterEach.forEach((mochaHook) => {
mochaHook.call(this);
});
});

// Ensure that uncaught exceptions between tests result in the tests failing.
// This works around an issue with mocha / karma-mocha, see
// https://github.com/karma-runner/karma-mocha/issues/227
let pendingError = null;
let pendingErrorNotice = null;

window.addEventListener('error', event => {
pendingError = event.error;
pendingErrorNotice = 'An uncaught exception was thrown between tests';
});

window.addEventListener('unhandledrejection', event => {
pendingError = event.reason;
pendingErrorNotice = 'An uncaught promise rejection occurred between tests';
});

afterEach(() => {
if (pendingError) {
console.error(pendingErrorNotice);
throw pendingError;
}
});

const packagesContext = require.context('../packages', true, /\.test\.tsx$/);
packagesContext.keys().forEach(packagesContext);
17 changes: 0 additions & 17 deletions test/utils/consoleError.js

This file was deleted.

4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2735,8 +2735,8 @@
resolved "https://github.com/mui-org/material-ui.git#3c078f2f6943976fc4d3ed5d886bbfa0f391e4a2"

"@material-ui/monorepo@https://github.com/mui-org/material-ui.git#next":
version "5.0.0-alpha.13"
resolved "https://github.com/mui-org/material-ui.git#13f3e9d8db81b40e1b08f43e4d45e37f3926c37d"
version "5.0.0-alpha.15"
resolved "https://github.com/mui-org/material-ui.git#c500fc3faf873142b9124319cebf728dd9a12cc5"

"@material-ui/styles@^4.10.0":
version "4.10.0"
Expand Down

0 comments on commit a21faff

Please sign in to comment.