Skip to content

Commit

Permalink
Merge pull request #1507 from LiskHQ/1464-setup-coverage-checks-for-j…
Browse files Browse the repository at this point in the history
…est-tests

Setup coverage checks for jest tests - Closes #1464
  • Loading branch information
Osvaldo Vega Agüero committed Nov 19, 2018
2 parents def4b5f + cf6d0eb commit 34abe8c
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 170 deletions.
250 changes: 80 additions & 170 deletions jest.config.js
@@ -1,170 +1,25 @@
module.exports = {
modulePaths: ['src/components'],
testMatch: [
// app
'<rootDir>/app/src/menu.test.js',
'<rootDir>/app/src/modules/autoUpdater.test.js',
'<rootDir>/app/src/modules/localeHandler.test.js',
'<rootDir>/app/src/modules/updateModal.test.js',
'<rootDir>/app/src/modules/win.test.js',

// src
'<rootDir>/src/actions/*test.js',
'<rootDir>/src/components/account/account.test.js',
'<rootDir>/src/components/account/index.test.js',
'<rootDir>/src/components/accountTransactions/index.test.js',
'<rootDir>/src/components/accountVisual/index.test.js',
'<rootDir>/src/components/actionBar/index.test.js',
'<rootDir>/src/components/app/index.test.js',
'<rootDir>/src/components/authenticate/authenticate.test.js',
'<rootDir>/src/components/authenticate/index.test.js',
'<rootDir>/src/components/authInputs/authInputs.test.js',
'<rootDir>/src/components/authInputs/index.test.js',
'<rootDir>/src/components/autoSuggest/index.test.js',
'<rootDir>/src/components/box/index.test.js',
'<rootDir>/src/components/confirmVotes/confirmVotes.test.js',
'<rootDir>/src/components/confirmVotes/index.test.js',
'<rootDir>/src/components/converter/converter.test.js',
'<rootDir>/src/components/converter/index.test.js',
'<rootDir>/src/components/copyToClipboard/index.test.js',
'<rootDir>/src/components/customRoute/index.test.js',
'<rootDir>/src/components/dashboard/currencyGraph.test.js',
'<rootDir>/src/components/dialog/alert.test.js',
'<rootDir>/src/components/dialog/dialog.test.js',
'<rootDir>/src/components/dialog/options.test.js',
'<rootDir>/src/components/errorBoundary/index.test.js',
'<rootDir>/src/components/followedAccounts/addAccountID.test.js',
'<rootDir>/src/components/followedAccounts/addAccountTitle.test.js',
'<rootDir>/src/components/followedAccounts/viewAccounts.test.js',
'<rootDir>/src/components/fontIcon/index.test.js',
'<rootDir>/src/components/formattedNumber/index.test.js',
'<rootDir>/src/components/header/countDownTemplate.test.js',
'<rootDir>/src/components/header/customCountDown.test.js',
'<rootDir>/src/components/header/header.test.js',
'<rootDir>/src/components/header/index.test.js',
'<rootDir>/src/components/help/help.test.js',
'<rootDir>/src/components/liskAmount/index.test.js',
'<rootDir>/src/components/loadingBar/index.test.js',
'<rootDir>/src/components/loadingBar/loadingBar.test.js',
'<rootDir>/src/components/login/index.test.js',
'<rootDir>/src/components/login/login.test.js',
'<rootDir>/src/components/mainMenu/index.test.js',
'<rootDir>/src/components/mainMenu/mainMenu.test.js',
'<rootDir>/src/components/menuBar/menuBar.test.js',
'<rootDir>/src/components/multiStep/index.test.js',
'<rootDir>/src/components/multiStep/multiStepNav.test.js',
'<rootDir>/src/components/newsFeed/index.test.js',
'<rootDir>/src/components/newsFeed/newsFeed.test.js',
'<rootDir>/src/components/newsFeed/settingsNewsFeed.test.js',
'<rootDir>/src/components/notFound/index.test.js',
'<rootDir>/src/components/offlineWrapper/index.test.js',
'<rootDir>/src/components/onboarding/onboarding.test.js',
'<rootDir>/src/components/parallax/index.test.js',
'<rootDir>/src/components/passphrase/confirm/form.test.js',
'<rootDir>/src/components/passphrase/confirm/index.test.js',
'<rootDir>/src/components/passphrase/ConfirmSecond/confirmSecond.test.js',
'<rootDir>/src/components/passphrase/ConfirmSecond/index.test.js',
'<rootDir>/src/components/passphrase/create/createFirst.test.js',
'<rootDir>/src/components/passphrase/create/movableShape.test.js',
'<rootDir>/src/components/passphrase/createSecond/create.test.js',
'<rootDir>/src/components/passphrase/info/index.test.js',
'<rootDir>/src/components/passphrase/safekeeping/index.test.js',
'<rootDir>/src/components/passphraseCreation/index.test.js',
'<rootDir>/src/components/passphraseInput/index.test.js',
'<rootDir>/src/components/pricedButton/index.test.js',
'<rootDir>/src/components/privateWrapper/index.test.js',
'<rootDir>/src/components/proxyDialog/index.test.js',
'<rootDir>/src/components/quickTips/index.test.js',
'<rootDir>/src/components/referenceInput/index.test.js',
'<rootDir>/src/components/register/index.test.js',
'<rootDir>/src/components/register/register.test.js',
'<rootDir>/src/components/registerDelegate/index.test.js',
'<rootDir>/src/components/registerDelegate/registerDelegate.test.js',
'<rootDir>/src/components/registerDelegate/steps/choose/choose.test.js',
'<rootDir>/src/components/registerDelegate/steps/confirm/confirm.test.js',
'<rootDir>/src/components/request/confirmRequest.test.js',
'<rootDir>/src/components/request/specifyRequest.test.js',
'<rootDir>/src/components/resultBox/resultBox.test.js',
'<rootDir>/src/components/searchBar/index.test.js',
'<rootDir>/src/components/searchResult/index.test.js',
'<rootDir>/src/components/searchResult/keyAction.test.js',
'<rootDir>/src/components/secondPassphrase/index.test.js',
'<rootDir>/src/components/secondPassphrase/secondPassphrase.test.js',
'<rootDir>/src/components/send/index.test.js',
'<rootDir>/src/components/send/steps/confim/confirm.test.js',
'<rootDir>/src/components/send/steps/confirm/index.test.js',
'<rootDir>/src/components/send/steps/form/form.test.js',
'<rootDir>/src/components/send/steps/form/index.test.js',
'<rootDir>/src/components/sendTo/followAccount.test.js',
'<rootDir>/src/components/sendTo/sendTo.test.js',
'<rootDir>/src/components/setting/index.test.js',
'<rootDir>/src/components/setting/setting.test.js',
'<rootDir>/src/components/sidechains/index.test.js',
'<rootDir>/src/components/signMessage/signMessage.test.js',
'<rootDir>/src/components/spinner/index.test.js',
'<rootDir>/src/components/timestamp/index.test.js',
'<rootDir>/src/components/toaster/index.test.js',
'<rootDir>/src/components/toaster/toaster.test.js',
'<rootDir>/src/components/toolbox/buttons/button.test.js',
'<rootDir>/src/components/toolbox/buttons/iconButton.test.js',
'<rootDir>/src/components/toolbox/sliderCheckbox/index.test.js',
'<rootDir>/src/components/toolbox/transitionWrapper/index.test.js',
'<rootDir>/src/components/transactions/amount.test.js',
'<rootDir>/src/components/transactions/delegateStatistics.test.js',
'<rootDir>/src/components/transactions/explorerTransactions/index.test.js',
'<rootDir>/src/components/transactions/status.test.js',
'<rootDir>/src/components/transactions/transactionDetailView.test.js',
'<rootDir>/src/components/transactions/transactionOverview.test.js',
'<rootDir>/src/components/transactions/transactionRow.test.js',
'<rootDir>/src/components/transactions/transactionsHeader.test.js',
'<rootDir>/src/components/transactions/transactionsList.test.js',
'<rootDir>/src/components/transactions/transactionType.test.js',
'<rootDir>/src/components/transactions/walletTransactions/index.test.js',
'<rootDir>/src/components/votesPreview/votesPreview.test.js',
'<rootDir>/src/components/voteUrlProcessor/index.test.js',
'<rootDir>/src/components/voteUrlProcessor/voteUrlProcessor.test.js',
'<rootDir>/src/components/voting/index.test.js',
'<rootDir>/src/components/voting/voting.test.js',
'<rootDir>/src/components/votingListView/delegateList.test.js',
'<rootDir>/src/components/votingListView/delegateRow.test.js',
'<rootDir>/src/components/votingListView/index.test.js',
'<rootDir>/src/components/votingListView/voteCheckbox.test.js',
'<rootDir>/src/components/votingListView/voteRow.test.js',
'<rootDir>/src/components/votingListView/votingHeader.test.js',
'<rootDir>/src/components/votingListView/votingListView.test.js',
'<rootDir>/src/store/**/*test.js',
'<rootDir>/src/utils/account.test.js',
'<rootDir>/src/utils/api/account.test.js',
'<rootDir>/src/utils/api/delegate.test.js',
'<rootDir>/src/utils/api/nethash.test.js',
'<rootDir>/src/utils/api/peers.test.js',
'<rootDir>/src/utils/api/search.test.js',
'<rootDir>/src/utils/api/transactions.test.js',
'<rootDir>/src/utils/app.test.js',
'<rootDir>/src/utils/delegates.test.js',
'<rootDir>/src/utils/externalLinks.test.js',
'<rootDir>/src/utils/followedAccounts.test.js',
'<rootDir>/src/utils/generateUniqueId.test.js',
'<rootDir>/src/utils/hacks.test.js',
'<rootDir>/src/utils/ipcLocale.test.js',
'<rootDir>/src/utils/isMobile.test.js',
'<rootDir>/src/utils/localJSONStorage.test.js',
'<rootDir>/src/utils/login.test.js',
'<rootDir>/src/utils/lsk.test.js',
'<rootDir>/src/utils/notification.test.js',
'<rootDir>/src/utils/passphrase.test.js',
'<rootDir>/src/utils/polyfills.test.js',
'<rootDir>/src/utils/similarWord.test.js',

// integration
'<rootDir>/test/integration/accountTransactions.test.js',
'<rootDir>/test/integration/dashboard.test.js',
'<rootDir>/test/integration/login.test.js',
'<rootDir>/test/integration/register.test.js',
'<rootDir>/test/integration/registerDelegate.test.js',
'<rootDir>/test/integration/transactionID.test.js',
'<rootDir>/test/integration/voting.test.js',
'<rootDir>/test/integration/wallet.test.js',
'<rootDir>/app/src/**/*.test.js',
'<rootDir>/src/**/*.test.js',
'<rootDir>/test/integration/*.test.js',
],
testPathIgnorePatterns: [
'src/actions/transactions.test.js',
'src/components/dashboard/currencyGraph.test.js', // This should be unskipped in issue #1499
'src/components/errorBoundary/index.test.js',
'src/components/feedbackForm/*.test.js',
'src/components/ledger/*.test.js',
'src/components/login/*.test.js',
'src/components/newsFeed/index.test.js', // This component doesn't meet the setted tresholds for mocha but in jest
'src/components/passphraseCreation/index.test.js',
'src/components/register/register.test.js',
'src/components/request/specifyRequest.test.js',
'src/components/transactions/votedDelegates.test.js',
'src/components/voteUrlProcessor/index.test.js',
'src/store/middlewares/login.test.js',
'src/store/reducers/liskService.test.js',
],
verbose: true,
cache: false,
Expand All @@ -177,18 +32,73 @@ module.exports = {
collectCoverage: true,
coverageDirectory: '<rootDir>/coverage/jest',
collectCoverageFrom: [
'<rootDir>/src/**/*.js',
'<rootDir>/app/src/**/*.js',
'src/**/*.js',
'app/src/**/*.js',
],
coveragePathIgnorePatterns: [
'/node_modules/',
'app/src/ipc.js',
'app/src/ledger.js',
'src/actions/liskService.js',
'src/actions/transactions.js',
'src/components/account/stories.js',
'src/components/backgroundMaker/index.js',
'src/components/dashboard/currencyGraph.js', // This should be unskipped in issue #1499
'src/components/dialog/stories.js',
'src/components/errorBoundary/index.js',
'src/components/feedbackForm/',
'src/components/formattedNumber/stories.js',
'src/components/ledger/',
'src/components/login/',
'src/components/newsFeed/index.js', // This component doesn't meet the setted tresholds for mocha but in jest
'src/components/newsFeed/news.js',
'src/components/passphrase/create/create.js',
'src/components/passphraseCreation/index.js',
'src/components/register/register.js',
'src/components/request/specifyRequest.js',
'src/components/searchBar/index.js', // Passing in mocha but not in Jest
'src/components/send/steps/form/stories.js',
'src/components/spinner/stories.js',
'src/components/toaster/stories.js',
'src/components/toolbox/transitionWrapper/index.js',
'src/components/transactions/transactions.js',
'src/components/transactions/votedDelegates.js',
'src/components/voteUrlProcessor/index.js',
'src/constants/',
'src/i18n-scanner.js',
'src/main.js',
'src/store/middlewares/login.js',
'src/store/reducers/liskService.js',
'src/tests.js',
'src/utils/api/ledger.js',
'src/utils/api/liskService.js',
'src/utils/applyDeviceClass.js',
'src/utils/ledger.js',
'src/utils/proxyLogin.js',
'src/utils/rawTransactionWrapper.js',
'src/utils/to.js',
],
coverageThreshold: {
global: {
branches: 75,
functions: 75,
lines: 75,
statements: 75,
branches: 90,
functions: 90,
lines: 90,
statements: 90,
},
'app/src/**/*.js': {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
'src/**/*.js': {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
'src/store/**/*.js': {
statements: 90,
},
},
setupFiles: [
Expand Down
16 changes: 16 additions & 0 deletions src/components/newsFeed/newsFeed.test.js
Expand Up @@ -71,6 +71,22 @@ describe('NewsFeed', () => {
expect(wrapper.find(SettingsNewsFeed).exists()).to.equal(true);
});

it('should render No feeds chosen', () => {
const newProps = {
channels: { test: true },
t,
getNewsFeed: () => {},
newsFeed: [],
showNewsFeedEmptyState: true,
};

const wrapper = mount(<MemoryRouter>
<NewsFeed {...newProps} />
</MemoryRouter>, options);
wrapper.find('.settingsButton').simulate('click');
expect(wrapper.find(SettingsNewsFeed).exists()).to.equal(true);
});

it('should render not SettingsNewsFeed', () => {
const wrapper = mount(<MemoryRouter>
<NewsFeed {...props} />
Expand Down
4 changes: 4 additions & 0 deletions src/components/searchBar/index.test.js
Expand Up @@ -36,6 +36,10 @@ describe('SearchBar', () => {
t: () => {},
searchSuggestions: () => {},
searchClearSuggestions: () => {},
location: {
pathname: 'explorer',
search: '',
},
};
options = {
context: {
Expand Down

0 comments on commit 34abe8c

Please sign in to comment.