Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New: Introduce Jest component testing to the framework (fixes #3417) #3383

Merged
merged 21 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
fde2476
Issue#64/Introduce Jest component testing to the framework starting w…
Mar 31, 2023
2748f5c
issue#64/reverted change to adapt-contri-core
Mar 31, 2023
b3f0dce
Issue#64 - removed view and model mock
Mar 31, 2023
4549638
Issue#64 - modified mocks to only include what was needed for the tes…
May 17, 2023
3b8cf3a
Issue#64 - removed device.screenSize setting within test as device.sc…
May 17, 2023
c51aa98
Issue#64 - fixed package.json conflicts
May 17, 2023
ca1e9b7
Issue#64 - header file path update after initialising the core submodule
May 17, 2023
04f2c7b
Removed coverage reports
May 17, 2023
94abb38
Git ignore all files within the coverage directory
May 17, 2023
c1868de
Added package-lock
May 17, 2023
1b1a5a2
removed displayTitle test
May 17, 2023
c0b4f2e
isScreenSizeMin Mock const
May 19, 2023
e3743b4
removed react helpers extported templates as is it not used in the js…
May 19, 2023
a5804fc
Extended with a custom jest environment to allow ES Class unit tests …
oliverfoster Jul 11, 2023
5672e7d
Fix: files moved to test folder, test preperation/execution seperated.
joe-allen-89 Aug 4, 2023
88ea3e4
Files removed from root after being added to test folder.
joe-allen-89 Aug 4, 2023
d8219c4
Refactor
oliverfoster Sep 19, 2023
b99959a
Pull jest-environment-adapt from npm instead of github
oliverfoster Sep 19, 2023
7b3e819
Merged with master
oliverfoster Sep 19, 2023
fb382fd
Added npm test help
oliverfoster Sep 19, 2023
7acc018
Updating testing environment to 16 and removed typo
oliverfoster Sep 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"browser": true,
"commonjs": false,
"es2022": true,
"amd": true
"amd": true,
"jest": true
},
"extends": [
"standard",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: "14"
node-version: "16"
cache: "npm"

- name: Installing Environment
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ bower_components
node_modules
.DS_Store
.idea
coverage
6 changes: 6 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const presets = [
['@babel/preset-env', { targets: { node: 'current' } }],
['@babel/preset-react', { targets: { node: 'current' } }]
];

module.exports = { presets };
4 changes: 3 additions & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost:9001/',
screenshotOnRunFailure: false,
video: false
video: false,
supportFile: false,
specPattern: '**/test/e2e/**/*.cy.{js,jsx}'
}
});
25 changes: 0 additions & 25 deletions cypress/support/commands.js

This file was deleted.

20 changes: 0 additions & 20 deletions cypress/support/e2e.js

This file was deleted.

Empty file removed index.js
Empty file.
197 changes: 197 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
/*
* For a detailed explanation regarding each configuration property, visit:
* https://jestjs.io/docs/configuration
*/
module.exports = {
// All imported modules in your tests should be mocked automatically
// automock: false,

// Stop running tests after `n` failures
// bail: 0,

// The directory where Jest should store its cached dependency information
// cacheDirectory: "/private/var/folders/2g/rf_zwp4514g9f5f3cqth9pwr0000gp/T/jest_dy",

// Automatically clear mock calls, instances, contexts and results before every test
clearMocks: true,

// Indicates whether the coverage information should be collected while executing the test
collectCoverage: true,

// An array of glob patterns indicating a set of files for which coverage information should be collected
// collectCoverageFrom: undefined,

// The directory where Jest should output its coverage files
coverageDirectory: 'coverage',

// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "/node_modules/"
// ],

// Indicates which provider should be used to instrument code for coverage
coverageProvider: 'v8',

// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
// "json",
// "text",
// "lcov",
// "clover"
// ],

// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: undefined,

// A path to a custom dependency extractor
// dependencyExtractor: undefined,

// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,

// The default configuration for fake timers
// fakeTimers: {
// "enableGlobally": false
// },

// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],

// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: undefined,

// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: undefined,

// A set of global variables that need to be available in all test environments
// globals: {},

// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
// maxWorkers: "50%",

// An array of directory names to be searched recursively up from the requiring module's location
moduleDirectories: [
'node_modules',
'build',
'src'
],

// An array of file extensions your modules use
// moduleFileExtensions: [
// "js",
// "mjs",
// "cjs",
// "jsx",
// "ts",
// "tsx",
// "json",
// "node"
// ],

// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
// moduleNameMapper: {},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],

// Activates notifications for test results
// notify: false,

// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",

// A preset that is used as a base for Jest's configuration
// preset: undefined,

// Run tests from one or more projects
// projects: undefined,

// Use this configuration option to add custom reporters to Jest
// reporters: undefined,

// Automatically reset mock state before every test
// resetMocks: false,

// Reset the module registry before running each individual test
// resetModules: false,

// A path to a custom resolver
// resolver: undefined,

// Automatically restore mock state and implementation before every test
// restoreMocks: false,

// The root directory that Jest should scan for tests and modules within
// rootDir: undefined,

// A list of paths to directories that Jest should use to search for files in
// roots: [
// "<rootDir>"
// ],

// Allows you to use a custom runner instead of Jest's default test runner
// runner: "jest-runner",
// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],

// The number of seconds after which a test is considered as slow and reported as such in the results.
// slowTestThreshold: 5,

// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],

// The test environment that will be used for testing
testEnvironment: 'jest-environment-adapt',

// Options that will be passed to the testEnvironment
testEnvironmentOptions: {
pluginsMockFile: './test/unit/__mocks__/plugins.js'
},

// Adds a location field to test results
// testLocationInResults: false,

// The glob patterns Jest uses to detect test files
testMatch: [
'**/test/unit/**/*.js?(x)',
'!**/__mocks__/**/*.js?(x)'
]

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],

// This option allows the use of a custom results processor
// testResultsProcessor: undefined,

// This option allows use of a custom test runner
// testRunner: "jest-circus/runner",

// A map from regular expressions to paths to transformers
// transform: undefined,

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/",
// "\\.pnp\\.[^\\/]+$"
// ],

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,

// Indicates whether each individual test should be reported during the run
// verbose: undefined,

// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],

// Whether to use watchman for file crawling
// watchman: true,
};
4 changes: 2 additions & 2 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"include": [
"src/core/js/**/*.js",
"src/*/*/js/**/*.js",
"src/core/js/**/*.jsx",
"src/*/*/js/**/*.jsx",
"src/core/templates/**/*.jsx",
"src/*/*/js/**/*.js",
"src/*/*/js/**/*.jsx",
"src/*/*/templates/**/*.jsx"
],
"compilerOptions": {
Expand Down
Loading