Skip to content

Commit

Permalink
chore(test): migrate away from done.fail() (#3309)
Browse files Browse the repository at this point in the history
`jest-circus`, the test runner we are using, does not seem to support
Jasmine `done.fail()` API.

Found in a CI for #3054.
  • Loading branch information
asudoh authored and emyarod committed Jul 9, 2019
1 parent 21dca10 commit 3b124f9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
32 changes: 17 additions & 15 deletions packages/components/tests/styles-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'use strict';

const path = require('path');
const { promisify } = require('util');
const sass = require('node-sass');
const glob = require('glob');

Expand All @@ -18,23 +19,24 @@ const files = glob.sync('**/*.scss', {
ignore: ['**/vendor/@carbon/**'],
});

const render = promisify(sass.render);

describe('styles', () => {
it.each(files)('%s should compile', (relativeFilePath, done) => {
it.each(files)('%s should compile', async relativeFilePath => {
const filepath = path.join(cwd, relativeFilePath);
sass.render(
{
file: filepath,
...defaultOptions,
},
(error, result) => {
if (error) {
const { column, line, message } = error;
done.fail(`${filepath}\n[${line}:${column}] ${message}`);
return;
}
expect(result.css).toBeDefined();
done();
try {
expect(
(await render({
file: filepath,
...defaultOptions,
})).css
).toBeDefined();
} catch (error) {
const { column, line, message } = error;
if (message) {
throw new Error(`${filepath}\n[${line}:${column}] ${message}`);
}
);
throw error;
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ describe('DatePicker', () => {
beforeEach(done => {
const spy = {};
spy.console = jest.spyOn(console, 'error').mockImplementation(e => {
done.fail(e);
done(e);
});
done();
});
Expand Down

0 comments on commit 3b124f9

Please sign in to comment.