Category: JavaScript
-
Post Views: 15 1. Report an error in the browser console: UncaughtSyntaxError: Invalid or Unexpected token (XXX.js). as shown in Figure 1 2. The last discovery is that the content of the JS file in the response contains \, and the content is escaped. as shown in Figure 2 3. After the \ is removed from the content of the…
-
Post Views: 32 1. Search in Githab: mocha, select the first one: mochajs/mocha, a simple, flexible and interesting JavaScript test framework for node.js and browsers. as shown in Figure 1 2. Click the link documentation to enterhttps://mochajs.org/ 3. Reference installation:https://mochajs.org/#installation, as a project development dependency, use npm to install, enter the project directory: npm install –save-dev mocha. as shown in…
-
Post Views: 17 1. Reference: In Refactoring: Improved Design of Existing Code (2nd Edition), build the test system – the writing of the sample code to be tested:https://www.shuijingwanwq.com/2023/01/28/7368/. The problem now is that multiple classes exist in the same file. Decided to split, each class forms a separate file. 2. Create a new class file /modules/producer.js, and migrate the class…
-
Post Views: 17 1. A code to be tested. This code comes from a simple application that supports users to view and adjust production plans. Its (slightly rough) interface looks like the picture below. as shown in Figure 1 2. The final implementation of the example code is as follows, the productionplan.html file code of the entrance is as follows…
-
Post Views: 19 1. UncaughtXError: Cannot use import statement outside a module (at statement.js:1:1). Reference: Refactoring: Improve the design of existing code (2nd edition). as shown in Figure 1 2. The code is implemented as follows, as shown in Figure 2 statement.html statement.js CreateStatementData.js 3. Reference:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Modules. JavaScript module. You need to put type=”module” into the script tag to declare that…
-
Post Views: 19 1. When learning to refactor: improve the design of the existing code (2nd edition), it is found that the function statement is missing 1 } at the end, which leads to the problem of the code format display. as shown in Figure 1 2. I have always mistakenly thought that the code itself was omitted }, so…
-
Post Views: 20 1. Lerna err! Yarn run prod exited 1 in@theme/objectError command failed with exit code 1. as shown in Figure 1 2. Decide to delete the directory: node_modules, and execute the yarn and yarn prod commands again.
-
Post Views: 17 1. The troupe stores the data of the play in a simple JSON file. 2. The bills they issued are also stored in a JSON file. 3. The following simple function is used to print the details of the bill. 4. Use the above data files (invoices.json and plays.json) as test input, run this code, you will…
-
Post Views: 73 1. When executing yarn, an error is reported: Failed to apply patch for package laravel-mix. patches\Laravel-mix+6.0.43.patch could not be parsed. as shown in Figure 1 2. Check the git log, the previous version of patches\Laravel-mix+6.0.43.patch is: patches\laravel-mix+6.0.48.patch. as shown in Figure 2 3. After deleting the directory: node_modules, execute again: yarn, and still report the same error.…
-
Post Views: 15 1. When executing the command: npm run build, prompt: npm err! missing script: “build”. as shown in Figure 1 2. Check the package.json file, you can confirm that the scripts does not contain the build script. as shown in Figure 2 3. According to the prompt: to see a list of scripts, run: npm run. To view…