canvas-lms/jest.config.js

72 lines
2.8 KiB
JavaScript
Raw Normal View History

/*
* Copyright (C) 2018 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const {defaults} = require('jest-config')
module.exports = {
moduleNameMapper: {
'^i18n!(.*$)': '<rootDir>/jest/i18nTransformer.js',
'\\.svg$': '<rootDir>/jest/imageMock.js',
add conference ui to calendar details page refs CAL-4 flag=calendar_conferences Test plan: - enable FF "Add Conferences from Calendar" and "Allow Conference Selection..." - enable BigBlueButton with dummy settings at /plugins/big_blue_button - create two courses, one with multiple sections - add LTI tool for conference selection to one course - open add calendar event dialog at /calendar - switch context to one of the courses - verify that conferencing options appear (two options if in course with LTI; one option otherwise) - click more options to open detailed edit page - verify that conferencing options appear the same way - add a conference - save the conference - verify that conference appears on the calendar - repeat in the other context to verify other select UI - add a conference before clicking "more options" and verify that it is included in the more options page - verfy that updating the conference and then cancelling on the more options page does not save the update - in the course with multiple sections, select "use a different date for each section" - verify that the conference for the parent event is shown for each of the child events in the calendar - verify that the conference can't be edited from the child events - verify that updating the parent event conference from the More Details page also updates the child events (as seen in the calendar) Change-Id: I9a7dccc9962d3c056f6a6a5fdb8a501ce8960c18 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/235298 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Ken McGrady <kmcgrady@instructure.com> QA-Review: Steve Shepherd <sshepherd@instructure.com> Product-Review: Michael Brewer-Davis <mbd@instructure.com>
2020-04-25 00:55:53 +08:00
'node_modules-version-of-backbone': require.resolve('backbone'),
'node_modules-version-of-react-modal': require.resolve('react-modal'),
'^Backbone$': '<rootDir>/public/javascripts/Backbone.js',
// jest can't import the icons
'@instructure/ui-icons/es/svg': '<rootDir>/packages/canvas-rce/src/rce/__tests__/_mockIcons.js',
// redirect imports from es/rce to lib
'@instructure/canvas-rce/es/rce/tinyRCE': '<rootDir>/packages/canvas-rce/lib/rce/tinyRCE.js',
'@instructure/canvas-rce/es/rce/RCE': '<rootDir>/packages/canvas-rce/lib/rce/RCE.js',
// mock the tinymce-react Editor react component
'@tinymce/tinymce-react': '<rootDir>/packages/canvas-rce/src/rce/__mocks__/tinymceReact.js'
},
roots: ['<rootDir>/ui', 'gems/plugins', 'public/javascripts'],
moduleDirectories: ['ui/shims', 'public/javascripts', 'node_modules'],
reporters: [
'default',
[
'jest-junit',
{
suiteName: 'Jest Tests',
outputDirectory: process.env.TEST_RESULT_OUTPUT_DIR || './coverage-js/junit-reports',
outputName: 'jest.xml'
}
]
],
snapshotSerializers: ['enzyme-to-json/serializer'],
setupFiles: ['jest-localstorage-mock', 'jest-canvas-mock', '<rootDir>/jest/jest-setup.js'],
Upgrade to babel 7 & allow any js file to be themeable closes: CORE-2699 CORE-2700 UIDEV-99 This commit gets canvas-lms itself upgraded to babel 7. To do that we also had to upgrade jest to v24. We had already got canvas-rce and canvas-planner on jest24/babel7 but now this gets everything to babel 7. so you will see a lot of things removed from yarn.lock since we don’t don’t have to have different versions of everything for babel and jest The other major thing this does is make it so any JS file in canvas can become an @instructure/ui-themeable themeable component. This means you no longer should have to put your css in app/stylesheets for any new react components that you are writing. Test plan: 1. Make sure that the perf of `yarn build:js` is on-par with what it was before. We pass everything through the themeable babel transform now so there is a chance it is slower. If it is majorly slower, we’ll have to figure something out. 2. run a production weback build. The common (or any bundle for that matter should get output exactly the same as it did before) things to manually qa check: * in a NODE_ENV=production enviornment, go to /accounts/site_admin/developer_keys * click the "+ Developer Key" button, it should open the modal. (there are selenium tests that do this, but it was one thing that had to be fixed to get jenkins to pass) * on a course that is set up as a master course, click on the thing that opens the blueprint courses tray. * verify that when you click "Associations" and "Sync History" links in that tray, that they dynamically load the webpack chunk for the modal contents for that thing and then the modal is shown (again, there are selenium specs that test that exact thing but it is always good to manually test it too) Change-Id: I802584228962b54480a500f8fe422f45c2dcac4c Reviewed-on: https://gerrit.instructure.com/183965 Tested-by: Jenkins Reviewed-by: Clay Diffrient <cdiffrient@instructure.com> QA-Review: Ryan Shaw <ryan@instructure.com> Product-Review: Ryan Shaw <ryan@instructure.com>
2019-03-06 05:20:27 +08:00
setupFilesAfterEnv: [
'@testing-library/jest-dom/extend-expect',
'./packages/validated-apollo/src/ValidatedApolloCleanup.js'
Upgrade to babel 7 & allow any js file to be themeable closes: CORE-2699 CORE-2700 UIDEV-99 This commit gets canvas-lms itself upgraded to babel 7. To do that we also had to upgrade jest to v24. We had already got canvas-rce and canvas-planner on jest24/babel7 but now this gets everything to babel 7. so you will see a lot of things removed from yarn.lock since we don’t don’t have to have different versions of everything for babel and jest The other major thing this does is make it so any JS file in canvas can become an @instructure/ui-themeable themeable component. This means you no longer should have to put your css in app/stylesheets for any new react components that you are writing. Test plan: 1. Make sure that the perf of `yarn build:js` is on-par with what it was before. We pass everything through the themeable babel transform now so there is a chance it is slower. If it is majorly slower, we’ll have to figure something out. 2. run a production weback build. The common (or any bundle for that matter should get output exactly the same as it did before) things to manually qa check: * in a NODE_ENV=production enviornment, go to /accounts/site_admin/developer_keys * click the "+ Developer Key" button, it should open the modal. (there are selenium tests that do this, but it was one thing that had to be fixed to get jenkins to pass) * on a course that is set up as a master course, click on the thing that opens the blueprint courses tray. * verify that when you click "Associations" and "Sync History" links in that tray, that they dynamically load the webpack chunk for the modal contents for that thing and then the modal is shown (again, there are selenium specs that test that exact thing but it is always good to manually test it too) Change-Id: I802584228962b54480a500f8fe422f45c2dcac4c Reviewed-on: https://gerrit.instructure.com/183965 Tested-by: Jenkins Reviewed-by: Clay Diffrient <cdiffrient@instructure.com> QA-Review: Ryan Shaw <ryan@instructure.com> Product-Review: Ryan Shaw <ryan@instructure.com>
2019-03-06 05:20:27 +08:00
],
testMatch: ['**/__tests__/**/?(*.)(spec|test).js'],
coverageDirectory: '<rootDir>/coverage-jest/',
moduleFileExtensions: [...defaults.moduleFileExtensions, 'coffee', 'handlebars'],
restoreMocks: true,
testEnvironment: 'jest-environment-jsdom-fourteen',
transform: {
'^i18n': '<rootDir>/jest/i18nTransformer.js',
'^.+\\.coffee': '<rootDir>/jest/coffeeTransformer.js',
'^.+\\.handlebars': '<rootDir>/jest/handlebarsTransformer.js',
'^.+\\.[jt]sx?$': 'babel-jest',
'\\.graphql$': 'jest-raw-loader'
}
}