提交依赖与构建产物
This commit is contained in:
707
node_modules/vitest/LICENSE.md
generated
vendored
Normal file
707
node_modules/vitest/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,707 @@
|
||||
# Vitest core license
|
||||
Vitest is released under the MIT license:
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021-Present Vitest Team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
# Licenses of bundled dependencies
|
||||
The published Vitest artifact additionally contains code with the following licenses:
|
||||
BSD-3-Clause, ISC, MIT
|
||||
|
||||
# Bundled dependencies:
|
||||
## @antfu/install-pkg
|
||||
License: MIT
|
||||
By: Anthony Fu
|
||||
Repository: git+https://github.com/antfu/install-pkg.git
|
||||
|
||||
> MIT License
|
||||
>
|
||||
> Copyright (c) 2021 Anthony Fu <https://github.com/antfu>
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all
|
||||
> copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
> SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## @sinonjs/commons
|
||||
License: BSD-3-Clause
|
||||
Repository: git+https://github.com/sinonjs/commons.git
|
||||
|
||||
> BSD 3-Clause License
|
||||
>
|
||||
> Copyright (c) 2018, Sinon.JS
|
||||
> All rights reserved.
|
||||
>
|
||||
> Redistribution and use in source and binary forms, with or without
|
||||
> modification, are permitted provided that the following conditions are met:
|
||||
>
|
||||
> * Redistributions of source code must retain the above copyright notice, this
|
||||
> list of conditions and the following disclaimer.
|
||||
>
|
||||
> * Redistributions in binary form must reproduce the above copyright notice,
|
||||
> this list of conditions and the following disclaimer in the documentation
|
||||
> and/or other materials provided with the distribution.
|
||||
>
|
||||
> * Neither the name of the copyright holder nor the names of its
|
||||
> contributors may be used to endorse or promote products derived from
|
||||
> this software without specific prior written permission.
|
||||
>
|
||||
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
> AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
> DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
> DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
> SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
> CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
> OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
> OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## @sinonjs/fake-timers
|
||||
License: BSD-3-Clause
|
||||
By: Christian Johansen
|
||||
Repository: git+https://github.com/sinonjs/fake-timers.git
|
||||
|
||||
> Copyright (c) 2010-2014, Christian Johansen, christian@cjohansen.no. All rights reserved.
|
||||
>
|
||||
> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
>
|
||||
> 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
>
|
||||
> 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
>
|
||||
> 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
>
|
||||
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## acorn-walk
|
||||
License: MIT
|
||||
By: Marijn Haverbeke, Ingvar Stepanyan, Adrian Heine
|
||||
Repository: https://github.com/acornjs/acorn.git
|
||||
|
||||
> MIT License
|
||||
>
|
||||
> Copyright (C) 2012-2020 by various contributors (see AUTHORS)
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in
|
||||
> all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
> THE SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## birpc
|
||||
License: MIT
|
||||
By: Anthony Fu
|
||||
Repository: git+https://github.com/antfu/birpc.git
|
||||
|
||||
> MIT License
|
||||
>
|
||||
> Copyright (c) 2021 Anthony Fu <https://github.com/antfu>
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all
|
||||
> copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
> SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## cac
|
||||
License: MIT
|
||||
By: egoist
|
||||
Repository: egoist/cac
|
||||
|
||||
> The MIT License (MIT)
|
||||
>
|
||||
> Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist)
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in
|
||||
> all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
> THE SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## chai-subset
|
||||
License: MIT
|
||||
By: Andrii Shumada, Robert Herhold
|
||||
Repository: https://github.com/debitoor/chai-subset.git
|
||||
|
||||
> The MIT License (MIT)
|
||||
>
|
||||
> Copyright (c) 2014
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all
|
||||
> copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
> SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## find-up
|
||||
License: MIT
|
||||
By: Sindre Sorhus
|
||||
Repository: sindresorhus/find-up
|
||||
|
||||
> MIT License
|
||||
>
|
||||
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## flatted
|
||||
License: ISC
|
||||
By: Andrea Giammarchi
|
||||
Repository: git+https://github.com/WebReflection/flatted.git
|
||||
|
||||
> ISC License
|
||||
>
|
||||
> Copyright (c) 2018-2020, Andrea Giammarchi, @WebReflection
|
||||
>
|
||||
> Permission to use, copy, modify, and/or distribute this software for any
|
||||
> purpose with or without fee is hereby granted, provided that the above
|
||||
> copyright notice and this permission notice appear in all copies.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
> REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
> AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
> INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
> LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||
> OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
> PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## js-tokens
|
||||
License: MIT
|
||||
By: Simon Lydell
|
||||
Repository: lydell/js-tokens
|
||||
|
||||
> The MIT License (MIT)
|
||||
>
|
||||
> Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 Simon Lydell
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in
|
||||
> all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
> THE SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## kleur
|
||||
License: MIT
|
||||
By: Luke Edwards
|
||||
Repository: lukeed/kleur
|
||||
|
||||
> The MIT License (MIT)
|
||||
>
|
||||
> Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in
|
||||
> all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
> THE SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## local-pkg
|
||||
License: MIT
|
||||
By: Anthony Fu
|
||||
Repository: git+https://github.com/antfu/local-pkg.git
|
||||
|
||||
> MIT License
|
||||
>
|
||||
> Copyright (c) 2021 Anthony Fu <https://github.com/antfu>
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all
|
||||
> copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
> SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## locate-path
|
||||
License: MIT
|
||||
By: Sindre Sorhus
|
||||
Repository: sindresorhus/locate-path
|
||||
|
||||
> MIT License
|
||||
>
|
||||
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## mime
|
||||
License: MIT
|
||||
By: Robert Kieffer
|
||||
Repository: https://github.com/broofa/mime
|
||||
|
||||
> MIT License
|
||||
>
|
||||
> Copyright (c) 2023 Robert Kieffer
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all
|
||||
> copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
> SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## mlly
|
||||
License: MIT
|
||||
Repository: unjs/mlly
|
||||
|
||||
> MIT License
|
||||
>
|
||||
> Copyright (c) Pooya Parsa <pooya@pi0.io>
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all
|
||||
> copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
> SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## p-limit
|
||||
License: MIT
|
||||
By: Sindre Sorhus
|
||||
Repository: sindresorhus/p-limit
|
||||
|
||||
> MIT License
|
||||
>
|
||||
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## p-locate
|
||||
License: MIT
|
||||
By: Sindre Sorhus
|
||||
Repository: sindresorhus/p-locate
|
||||
|
||||
> MIT License
|
||||
>
|
||||
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## package-manager-detector
|
||||
License: MIT
|
||||
By: Anthony Fu
|
||||
Repository: git+https://github.com/antfu-collective/package-manager-detector.git
|
||||
|
||||
> MIT License
|
||||
>
|
||||
> Copyright (c) 2020-PRESENT Anthony Fu <https://github.com/antfu>
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all
|
||||
> copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
> SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## prompts
|
||||
License: MIT
|
||||
By: Terkel Gjervig
|
||||
Repository: terkelg/prompts
|
||||
|
||||
> MIT License
|
||||
>
|
||||
> Copyright (c) 2018 Terkel Gjervig Nielsen
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all
|
||||
> copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
> SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## quansync
|
||||
License: MIT
|
||||
By: Anthony Fu, 三咲智子 Kevin Deng
|
||||
Repository: git+https://github.com/quansync-dev/quansync.git
|
||||
|
||||
> MIT License
|
||||
>
|
||||
> Copyright (c) 2025-PRESENT Anthony Fu <https://github.com/antfu> and Kevin Deng <https://github.com/sxzz>
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all
|
||||
> copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
> SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## sisteransi
|
||||
License: MIT
|
||||
By: Terkel Gjervig
|
||||
Repository: https://github.com/terkelg/sisteransi
|
||||
|
||||
> MIT License
|
||||
>
|
||||
> Copyright (c) 2018 Terkel Gjervig Nielsen
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all
|
||||
> copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
> SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## strip-literal
|
||||
License: MIT
|
||||
By: Anthony Fu
|
||||
Repository: git+https://github.com/antfu/strip-literal.git
|
||||
|
||||
> MIT License
|
||||
>
|
||||
> Copyright (c) 2022 Anthony Fu <https://github.com/antfu>
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all
|
||||
> copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
> SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## type-detect
|
||||
License: MIT
|
||||
By: Jake Luer, Keith Cirkel, David Losert, Aleksey Shvayka, Lucas Fernandes da Costa, Grant Snodgrass, Jeremy Tice, Edward Betts, dvlsg, Amila Welihinda, Jake Champion, Miroslav Bajtoš
|
||||
Repository: git+ssh://git@github.com/chaijs/type-detect.git
|
||||
|
||||
> Copyright (c) 2013 Jake Luer <jake@alogicalparadox.com> (http://alogicalparadox.com)
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in
|
||||
> all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
> THE SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## ufo
|
||||
License: MIT
|
||||
Repository: unjs/ufo
|
||||
|
||||
> MIT License
|
||||
>
|
||||
> Copyright (c) Pooya Parsa <pooya@pi0.io>
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all
|
||||
> copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
> SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## ws
|
||||
License: MIT
|
||||
By: Einar Otto Stangvik
|
||||
Repository: git+https://github.com/websockets/ws.git
|
||||
|
||||
> Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
||||
> Copyright (c) 2013 Arnout Kazemier and contributors
|
||||
> Copyright (c) 2016 Luigi Pinca and contributors
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
> this software and associated documentation files (the "Software"), to deal in
|
||||
> the Software without restriction, including without limitation the rights to
|
||||
> use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
> the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
> subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all
|
||||
> copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
> FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
> COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
> IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
## yocto-queue
|
||||
License: MIT
|
||||
By: Sindre Sorhus
|
||||
Repository: sindresorhus/yocto-queue
|
||||
|
||||
> MIT License
|
||||
>
|
||||
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
7
node_modules/vitest/README.md
generated
vendored
Normal file
7
node_modules/vitest/README.md
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# vitest
|
||||
|
||||
[](https://www.npmjs.com/package/vitest)
|
||||
|
||||
Next generation testing framework powered by Vite.
|
||||
|
||||
[GitHub](https://github.com/vitest-dev/vitest) | [Documentation](https://vitest.dev/)
|
||||
1
node_modules/vitest/browser.d.ts
generated
vendored
Normal file
1
node_modules/vitest/browser.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/browser.js'
|
||||
3
node_modules/vitest/config.d.ts
generated
vendored
Normal file
3
node_modules/vitest/config.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
// ensure `@vitest/expect` provides `chai` types
|
||||
import type {} from '@vitest/expect'
|
||||
export * from './dist/config.js'
|
||||
1
node_modules/vitest/coverage.d.ts
generated
vendored
Normal file
1
node_modules/vitest/coverage.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/coverage.js'
|
||||
34
node_modules/vitest/dist/browser.d.ts
generated
vendored
Normal file
34
node_modules/vitest/dist/browser.d.ts
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import { S as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.BKdhh7Zx.js';
|
||||
import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.S9RMNXIe.js';
|
||||
import { SerializedDiffOptions } from '@vitest/utils/diff';
|
||||
import { VitestExecutor } from './execute.js';
|
||||
export { collectTests, processError, startTests } from '@vitest/runner';
|
||||
import * as spy from '@vitest/spy';
|
||||
export { spy as SpyModule };
|
||||
export { LoupeOptions, ParsedStack, StringifyOptions, format, getSafeTimers, inspect, stringify } from '@vitest/utils';
|
||||
export { TraceMap, originalPositionFor } from '@vitest/utils/source-map';
|
||||
import '@vitest/pretty-format';
|
||||
import '@vitest/snapshot';
|
||||
import '@vitest/snapshot/environment';
|
||||
import 'vite-node/client';
|
||||
import 'vite-node';
|
||||
import './chunks/worker.d.CUgIPz9V.js';
|
||||
import './chunks/environment.d.cL3nLXbE.js';
|
||||
import 'vitest/optional-types.js';
|
||||
import 'node:vm';
|
||||
import '@vitest/mocker';
|
||||
import './chunks/mocker.d.BE_2ls6u.js';
|
||||
|
||||
declare function startCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: RuntimeCoverageModuleLoader, runtimeOptions: {
|
||||
isolate: boolean
|
||||
}): Promise<unknown>;
|
||||
declare function takeCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: RuntimeCoverageModuleLoader): Promise<unknown>;
|
||||
declare function stopCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: RuntimeCoverageModuleLoader, runtimeOptions: {
|
||||
isolate: boolean
|
||||
}): Promise<unknown>;
|
||||
|
||||
declare function setupCommonEnv(config: SerializedConfig): Promise<void>;
|
||||
declare function loadDiffConfig(config: SerializedConfig, executor: VitestExecutor): Promise<SerializedDiffOptions | undefined>;
|
||||
declare function loadSnapshotSerializers(config: SerializedConfig, executor: VitestExecutor): Promise<void>;
|
||||
|
||||
export { loadDiffConfig, loadSnapshotSerializers, setupCommonEnv, startCoverageInsideWorker, stopCoverageInsideWorker, takeCoverageInsideWorker };
|
||||
8
node_modules/vitest/dist/browser.js
generated
vendored
Normal file
8
node_modules/vitest/dist/browser.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export { l as loadDiffConfig, b as loadSnapshotSerializers, c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.Dd054P77.js';
|
||||
export { collectTests, processError, startTests } from '@vitest/runner';
|
||||
import * as spy from '@vitest/spy';
|
||||
export { spy as SpyModule };
|
||||
export { format, getSafeTimers, inspect, stringify } from '@vitest/utils';
|
||||
export { TraceMap, originalPositionFor } from '@vitest/utils/source-map';
|
||||
import './chunks/coverage.DVF1vEu8.js';
|
||||
import '@vitest/snapshot';
|
||||
7
node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js
generated
vendored
Normal file
7
node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
||||
|
||||
function getDefaultExportFromCjs (x) {
|
||||
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
||||
}
|
||||
|
||||
export { commonjsGlobal as c, getDefaultExportFromCjs as g };
|
||||
38
node_modules/vitest/dist/chunks/base.DfmxU-tU.js
generated
vendored
Normal file
38
node_modules/vitest/dist/chunks/base.DfmxU-tU.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
import { ModuleCacheMap } from 'vite-node/client';
|
||||
import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.B7h3T_Hc.js';
|
||||
import { p as provideWorkerState } from './utils.XdZDrNZV.js';
|
||||
|
||||
let _viteNode;
|
||||
const moduleCache = new ModuleCacheMap();
|
||||
const moduleExecutionInfo = /* @__PURE__ */ new Map();
|
||||
async function startViteNode(options) {
|
||||
if (_viteNode) return _viteNode;
|
||||
_viteNode = await startVitestExecutor(options);
|
||||
return _viteNode;
|
||||
}
|
||||
async function runBaseTests(method, state) {
|
||||
const { ctx } = state;
|
||||
// state has new context, but we want to reuse existing ones
|
||||
state.moduleCache = moduleCache;
|
||||
state.moduleExecutionInfo = moduleExecutionInfo;
|
||||
provideWorkerState(globalThis, state);
|
||||
if (ctx.invalidates) ctx.invalidates.forEach((fsPath) => {
|
||||
moduleCache.delete(fsPath);
|
||||
moduleCache.delete(`mock:${fsPath}`);
|
||||
});
|
||||
ctx.files.forEach((i) => state.moduleCache.delete(typeof i === "string" ? i : i.filepath));
|
||||
const [executor, { run }] = await Promise.all([startViteNode({
|
||||
state,
|
||||
requestStubs: getDefaultRequestStubs()
|
||||
}), import('./runBaseTests.9Ij9_de-.js')]);
|
||||
const fileSpecs = ctx.files.map((f) => typeof f === "string" ? {
|
||||
filepath: f,
|
||||
testLocations: void 0
|
||||
} : f);
|
||||
await run(method, fileSpecs, ctx.config, {
|
||||
environment: state.environment,
|
||||
options: ctx.environment.options
|
||||
}, executor);
|
||||
}
|
||||
|
||||
export { runBaseTests as r };
|
||||
37
node_modules/vitest/dist/chunks/benchmark.CYdenmiT.js
generated
vendored
Normal file
37
node_modules/vitest/dist/chunks/benchmark.CYdenmiT.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import { getCurrentSuite } from '@vitest/runner';
|
||||
import { createChainable } from '@vitest/runner/utils';
|
||||
import { noop } from '@vitest/utils';
|
||||
import { g as getWorkerState } from './utils.XdZDrNZV.js';
|
||||
|
||||
const benchFns = /* @__PURE__ */ new WeakMap();
|
||||
const benchOptsMap = /* @__PURE__ */ new WeakMap();
|
||||
function getBenchOptions(key) {
|
||||
return benchOptsMap.get(key);
|
||||
}
|
||||
function getBenchFn(key) {
|
||||
return benchFns.get(key);
|
||||
}
|
||||
const bench = createBenchmark(function(name, fn = noop, options = {}) {
|
||||
if (getWorkerState().config.mode !== "benchmark") throw new Error("`bench()` is only available in benchmark mode.");
|
||||
const task = getCurrentSuite().task(formatName(name), {
|
||||
...this,
|
||||
meta: { benchmark: true }
|
||||
});
|
||||
benchFns.set(task, fn);
|
||||
benchOptsMap.set(task, options);
|
||||
});
|
||||
function createBenchmark(fn) {
|
||||
const benchmark = createChainable([
|
||||
"skip",
|
||||
"only",
|
||||
"todo"
|
||||
], fn);
|
||||
benchmark.skipIf = (condition) => condition ? benchmark.skip : benchmark;
|
||||
benchmark.runIf = (condition) => condition ? benchmark : benchmark.skip;
|
||||
return benchmark;
|
||||
}
|
||||
function formatName(name) {
|
||||
return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
|
||||
}
|
||||
|
||||
export { getBenchOptions as a, bench as b, getBenchFn as g };
|
||||
24
node_modules/vitest/dist/chunks/benchmark.d.BwvBVTda.d.ts
generated
vendored
Normal file
24
node_modules/vitest/dist/chunks/benchmark.d.BwvBVTda.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Test } from '@vitest/runner';
|
||||
import { ChainableFunction } from '@vitest/runner/utils';
|
||||
import { TaskResult, Bench, Options } from 'tinybench';
|
||||
|
||||
interface Benchmark extends Test {
|
||||
meta: {
|
||||
benchmark: true
|
||||
result?: TaskResult
|
||||
};
|
||||
}
|
||||
interface BenchmarkResult extends TaskResult {
|
||||
name: string;
|
||||
rank: number;
|
||||
sampleCount: number;
|
||||
median: number;
|
||||
}
|
||||
type BenchFunction = (this: Bench) => Promise<void> | void;
|
||||
type ChainableBenchmarkAPI = ChainableFunction<"skip" | "only" | "todo", (name: string | Function, fn?: BenchFunction, options?: Options) => void>;
|
||||
type BenchmarkAPI = ChainableBenchmarkAPI & {
|
||||
skipIf: (condition: any) => ChainableBenchmarkAPI
|
||||
runIf: (condition: any) => ChainableBenchmarkAPI
|
||||
};
|
||||
|
||||
export type { BenchmarkResult as B, BenchFunction as a, Benchmark as b, BenchmarkAPI as c };
|
||||
1469
node_modules/vitest/dist/chunks/cac.0BJqEUeA.js
generated
vendored
Normal file
1469
node_modules/vitest/dist/chunks/cac.0BJqEUeA.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
10660
node_modules/vitest/dist/chunks/cli-api.DWGBtMmz.js
generated
vendored
Normal file
10660
node_modules/vitest/dist/chunks/cli-api.DWGBtMmz.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
224
node_modules/vitest/dist/chunks/config.d.BKdhh7Zx.d.ts
generated
vendored
Normal file
224
node_modules/vitest/dist/chunks/config.d.BKdhh7Zx.d.ts
generated
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
import { PrettyFormatOptions } from '@vitest/pretty-format';
|
||||
import { SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
|
||||
import { SnapshotUpdateState } from '@vitest/snapshot';
|
||||
import { SnapshotEnvironment } from '@vitest/snapshot/environment';
|
||||
import { SerializedDiffOptions } from '@vitest/utils/diff';
|
||||
|
||||
/**
|
||||
* Names of clock methods that may be faked by install.
|
||||
*/
|
||||
type FakeMethod =
|
||||
| "setTimeout"
|
||||
| "clearTimeout"
|
||||
| "setImmediate"
|
||||
| "clearImmediate"
|
||||
| "setInterval"
|
||||
| "clearInterval"
|
||||
| "Date"
|
||||
| "nextTick"
|
||||
| "hrtime"
|
||||
| "requestAnimationFrame"
|
||||
| "cancelAnimationFrame"
|
||||
| "requestIdleCallback"
|
||||
| "cancelIdleCallback"
|
||||
| "performance"
|
||||
| "queueMicrotask";
|
||||
|
||||
interface FakeTimerInstallOpts {
|
||||
/**
|
||||
* Installs fake timers with the specified unix epoch (default: 0)
|
||||
*/
|
||||
now?: number | Date | undefined;
|
||||
|
||||
/**
|
||||
* An array with names of global methods and APIs to fake.
|
||||
* For instance, `vi.useFakeTimer({ toFake: ['setTimeout', 'performance'] })` will fake only `setTimeout()` and `performance.now()`
|
||||
* @default everything available globally except `nextTick`
|
||||
*/
|
||||
toFake?: FakeMethod[] | undefined;
|
||||
|
||||
/**
|
||||
* The maximum number of timers that will be run when calling runAll()
|
||||
* @default 10000
|
||||
*/
|
||||
loopLimit?: number | undefined;
|
||||
|
||||
/**
|
||||
* Tells @sinonjs/fake-timers to increment mocked time automatically based on the real system time shift (e.g. the mocked time will be incremented by
|
||||
* 20ms for every 20ms change in the real system time) (default: false)
|
||||
*/
|
||||
shouldAdvanceTime?: boolean | undefined;
|
||||
|
||||
/**
|
||||
* Relevant only when using with shouldAdvanceTime: true. increment mocked time by advanceTimeDelta ms every advanceTimeDelta ms change
|
||||
* in the real system time (default: 20)
|
||||
*/
|
||||
advanceTimeDelta?: number | undefined;
|
||||
|
||||
/**
|
||||
* Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers.
|
||||
* @default true
|
||||
*/
|
||||
shouldClearNativeTimers?: boolean | undefined;
|
||||
|
||||
/**
|
||||
* Don't throw error when asked to fake timers that are not present.
|
||||
* @default false
|
||||
*/
|
||||
ignoreMissingTimers?: boolean | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Config that tests have access to.
|
||||
*/
|
||||
interface SerializedConfig {
|
||||
name: string | undefined;
|
||||
globals: boolean;
|
||||
base: string | undefined;
|
||||
snapshotEnvironment?: string;
|
||||
disableConsoleIntercept: boolean | undefined;
|
||||
runner: string | undefined;
|
||||
isolate: boolean;
|
||||
mode: "test" | "benchmark";
|
||||
bail: number | undefined;
|
||||
environmentOptions?: Record<string, any>;
|
||||
root: string;
|
||||
setupFiles: string[];
|
||||
passWithNoTests: boolean;
|
||||
testNamePattern: RegExp | undefined;
|
||||
allowOnly: boolean;
|
||||
testTimeout: number;
|
||||
hookTimeout: number;
|
||||
clearMocks: boolean;
|
||||
mockReset: boolean;
|
||||
restoreMocks: boolean;
|
||||
unstubGlobals: boolean;
|
||||
unstubEnvs: boolean;
|
||||
// TODO: make optional
|
||||
fakeTimers: FakeTimerInstallOpts;
|
||||
maxConcurrency: number;
|
||||
defines: Record<string, any>;
|
||||
expect: {
|
||||
requireAssertions?: boolean
|
||||
poll?: {
|
||||
timeout?: number
|
||||
interval?: number
|
||||
}
|
||||
};
|
||||
printConsoleTrace: boolean | undefined;
|
||||
sequence: {
|
||||
shuffle?: boolean
|
||||
concurrent?: boolean
|
||||
seed: number
|
||||
hooks: SequenceHooks
|
||||
setupFiles: SequenceSetupFiles
|
||||
};
|
||||
poolOptions: {
|
||||
forks: {
|
||||
singleFork: boolean
|
||||
isolate: boolean
|
||||
}
|
||||
threads: {
|
||||
singleThread: boolean
|
||||
isolate: boolean
|
||||
}
|
||||
vmThreads: {
|
||||
singleThread: boolean
|
||||
}
|
||||
vmForks: {
|
||||
singleFork: boolean
|
||||
}
|
||||
};
|
||||
deps: {
|
||||
web: {
|
||||
transformAssets?: boolean
|
||||
transformCss?: boolean
|
||||
transformGlobPattern?: RegExp | RegExp[]
|
||||
}
|
||||
optimizer: {
|
||||
web: {
|
||||
enabled: boolean
|
||||
}
|
||||
ssr: {
|
||||
enabled: boolean
|
||||
}
|
||||
}
|
||||
interopDefault: boolean | undefined
|
||||
moduleDirectories: string[] | undefined
|
||||
};
|
||||
snapshotOptions: {
|
||||
updateSnapshot: SnapshotUpdateState
|
||||
expand: boolean | undefined
|
||||
snapshotFormat: PrettyFormatOptions | undefined
|
||||
/**
|
||||
* only exists for tests, not available in the main process
|
||||
*/
|
||||
snapshotEnvironment: SnapshotEnvironment
|
||||
};
|
||||
pool: string;
|
||||
snapshotSerializers: string[];
|
||||
chaiConfig: {
|
||||
includeStack?: boolean
|
||||
showDiff?: boolean
|
||||
truncateThreshold?: number
|
||||
} | undefined;
|
||||
api: {
|
||||
allowExec: boolean | undefined
|
||||
allowWrite: boolean | undefined
|
||||
};
|
||||
diff: string | SerializedDiffOptions | undefined;
|
||||
retry: number;
|
||||
includeTaskLocation: boolean | undefined;
|
||||
inspect: boolean | string | undefined;
|
||||
inspectBrk: boolean | string | undefined;
|
||||
inspector: {
|
||||
enabled?: boolean
|
||||
port?: number
|
||||
host?: string
|
||||
waitForDebugger?: boolean
|
||||
};
|
||||
watch: boolean;
|
||||
env: Record<string, any>;
|
||||
browser: {
|
||||
name: string
|
||||
headless: boolean
|
||||
isolate: boolean
|
||||
fileParallelism: boolean
|
||||
ui: boolean
|
||||
viewport: {
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
locators: {
|
||||
testIdAttribute: string
|
||||
}
|
||||
screenshotFailures: boolean
|
||||
providerOptions: {
|
||||
// for playwright
|
||||
actionTimeout?: number
|
||||
}
|
||||
};
|
||||
standalone: boolean;
|
||||
logHeapUsage: boolean | undefined;
|
||||
coverage: SerializedCoverageConfig;
|
||||
benchmark: {
|
||||
includeSamples: boolean
|
||||
} | undefined;
|
||||
}
|
||||
interface SerializedCoverageConfig {
|
||||
provider: "istanbul" | "v8" | "custom" | undefined;
|
||||
reportsDirectory: string;
|
||||
htmlReporter: {
|
||||
subdir: string | undefined
|
||||
} | undefined;
|
||||
enabled: boolean;
|
||||
customProviderModule: string | undefined;
|
||||
}
|
||||
type RuntimeConfig = Pick<SerializedConfig, "allowOnly" | "testTimeout" | "hookTimeout" | "clearMocks" | "mockReset" | "restoreMocks" | "fakeTimers" | "maxConcurrency" | "expect" | "printConsoleTrace"> & {
|
||||
sequence?: {
|
||||
hooks?: SequenceHooks
|
||||
}
|
||||
};
|
||||
type RuntimeOptions = Partial<RuntimeConfig>;
|
||||
|
||||
export type { FakeTimerInstallOpts as F, RuntimeOptions as R, SerializedCoverageConfig as S, SerializedConfig as a, RuntimeConfig as b };
|
||||
153
node_modules/vitest/dist/chunks/console.CtFJOzRO.js
generated
vendored
Normal file
153
node_modules/vitest/dist/chunks/console.CtFJOzRO.js
generated
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
import { Console } from 'node:console';
|
||||
import { relative } from 'node:path';
|
||||
import { Writable } from 'node:stream';
|
||||
import { getSafeTimers } from '@vitest/utils';
|
||||
import c from 'tinyrainbow';
|
||||
import { R as RealDate } from './date.Bq6ZW5rf.js';
|
||||
import { g as getWorkerState } from './utils.XdZDrNZV.js';
|
||||
|
||||
const UNKNOWN_TEST_ID = "__vitest__unknown_test__";
|
||||
function getTaskIdByStack(root) {
|
||||
const stack = new Error("STACK_TRACE_ERROR").stack?.split("\n");
|
||||
if (!stack) return UNKNOWN_TEST_ID;
|
||||
const index = stack.findIndex((line) => line.includes("at Console.value"));
|
||||
const line = index === -1 ? null : stack[index + 2];
|
||||
if (!line) return UNKNOWN_TEST_ID;
|
||||
const filepath = line.match(/at\s(.*)\s?/)?.[1];
|
||||
if (filepath) return relative(root, filepath);
|
||||
return UNKNOWN_TEST_ID;
|
||||
}
|
||||
function createCustomConsole(defaultState) {
|
||||
const stdoutBuffer = /* @__PURE__ */ new Map();
|
||||
const stderrBuffer = /* @__PURE__ */ new Map();
|
||||
const timers = /* @__PURE__ */ new Map();
|
||||
const { queueMicrotask } = getSafeTimers();
|
||||
function queueCancelableMicrotask(callback) {
|
||||
let canceled = false;
|
||||
queueMicrotask(() => {
|
||||
if (!canceled) callback();
|
||||
});
|
||||
return () => {
|
||||
canceled = true;
|
||||
};
|
||||
}
|
||||
const state = () => defaultState || getWorkerState();
|
||||
// group sync console.log calls with micro task
|
||||
function schedule(taskId) {
|
||||
const timer = timers.get(taskId);
|
||||
const { stdoutTime, stderrTime } = timer;
|
||||
timer.cancel?.();
|
||||
timer.cancel = queueCancelableMicrotask(() => {
|
||||
if (stderrTime < stdoutTime) {
|
||||
sendStderr(taskId);
|
||||
sendStdout(taskId);
|
||||
} else {
|
||||
sendStdout(taskId);
|
||||
sendStderr(taskId);
|
||||
}
|
||||
});
|
||||
}
|
||||
function sendStdout(taskId) {
|
||||
sendBuffer("stdout", taskId);
|
||||
}
|
||||
function sendStderr(taskId) {
|
||||
sendBuffer("stderr", taskId);
|
||||
}
|
||||
function sendBuffer(type, taskId) {
|
||||
const buffers = type === "stdout" ? stdoutBuffer : stderrBuffer;
|
||||
const buffer = buffers.get(taskId);
|
||||
if (!buffer) return;
|
||||
if (state().config.printConsoleTrace) buffer.forEach(([buffer, origin]) => {
|
||||
sendLog(type, taskId, String(buffer), buffer.length, origin);
|
||||
});
|
||||
else {
|
||||
const content = buffer.map((i) => String(i[0])).join("");
|
||||
sendLog(type, taskId, content, buffer.length);
|
||||
}
|
||||
const timer = timers.get(taskId);
|
||||
buffers.delete(taskId);
|
||||
if (type === "stderr") timer.stderrTime = 0;
|
||||
else timer.stdoutTime = 0;
|
||||
}
|
||||
function sendLog(type, taskId, content, size, origin) {
|
||||
const timer = timers.get(taskId);
|
||||
const time = type === "stderr" ? timer.stderrTime : timer.stdoutTime;
|
||||
state().rpc.onUserConsoleLog({
|
||||
type,
|
||||
content: content || "<empty line>",
|
||||
taskId,
|
||||
time: time || RealDate.now(),
|
||||
size,
|
||||
origin
|
||||
});
|
||||
}
|
||||
const stdout = new Writable({ write(data, encoding, callback) {
|
||||
const s = state();
|
||||
const id = s?.current?.id || s?.current?.suite?.id || s.current?.file.id || getTaskIdByStack(s.config.root);
|
||||
let timer = timers.get(id);
|
||||
if (timer) timer.stdoutTime = timer.stdoutTime || RealDate.now();
|
||||
else {
|
||||
timer = {
|
||||
stdoutTime: RealDate.now(),
|
||||
stderrTime: RealDate.now()
|
||||
};
|
||||
timers.set(id, timer);
|
||||
}
|
||||
let buffer = stdoutBuffer.get(id);
|
||||
if (!buffer) {
|
||||
buffer = [];
|
||||
stdoutBuffer.set(id, buffer);
|
||||
}
|
||||
if (state().config.printConsoleTrace) {
|
||||
const limit = Error.stackTraceLimit;
|
||||
Error.stackTraceLimit = limit + 6;
|
||||
const stack = new Error("STACK_TRACE").stack;
|
||||
const trace = stack?.split("\n").slice(7).join("\n");
|
||||
Error.stackTraceLimit = limit;
|
||||
buffer.push([data, trace]);
|
||||
} else buffer.push([data, void 0]);
|
||||
schedule(id);
|
||||
callback();
|
||||
} });
|
||||
const stderr = new Writable({ write(data, encoding, callback) {
|
||||
const s = state();
|
||||
const id = s?.current?.id || s?.current?.suite?.id || s.current?.file.id || getTaskIdByStack(s.config.root);
|
||||
let timer = timers.get(id);
|
||||
if (timer) timer.stderrTime = timer.stderrTime || RealDate.now();
|
||||
else {
|
||||
timer = {
|
||||
stderrTime: RealDate.now(),
|
||||
stdoutTime: RealDate.now()
|
||||
};
|
||||
timers.set(id, timer);
|
||||
}
|
||||
let buffer = stderrBuffer.get(id);
|
||||
if (!buffer) {
|
||||
buffer = [];
|
||||
stderrBuffer.set(id, buffer);
|
||||
}
|
||||
if (state().config.printConsoleTrace) {
|
||||
const limit = Error.stackTraceLimit;
|
||||
Error.stackTraceLimit = limit + 6;
|
||||
const stack = new Error("STACK_TRACE").stack?.split("\n");
|
||||
Error.stackTraceLimit = limit;
|
||||
const isTrace = stack?.some((line) => line.includes("at Console.trace"));
|
||||
if (isTrace) buffer.push([data, void 0]);
|
||||
else {
|
||||
const trace = stack?.slice(7).join("\n");
|
||||
Error.stackTraceLimit = limit;
|
||||
buffer.push([data, trace]);
|
||||
}
|
||||
} else buffer.push([data, void 0]);
|
||||
schedule(id);
|
||||
callback();
|
||||
} });
|
||||
return new Console({
|
||||
stdout,
|
||||
stderr,
|
||||
colorMode: c.isColorSupported,
|
||||
groupIndentation: 2
|
||||
});
|
||||
}
|
||||
|
||||
export { UNKNOWN_TEST_ID, createCustomConsole };
|
||||
44
node_modules/vitest/dist/chunks/constants.DnKduX2e.js
generated
vendored
Normal file
44
node_modules/vitest/dist/chunks/constants.DnKduX2e.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
// if changed, update also jsdocs and docs
|
||||
const defaultPort = 51204;
|
||||
const defaultBrowserPort = 63315;
|
||||
const defaultInspectPort = 9229;
|
||||
const API_PATH = "/__vitest_api__";
|
||||
const extraInlineDeps = [
|
||||
/^(?!.*node_modules).*\.mjs$/,
|
||||
/^(?!.*node_modules).*\.cjs\.js$/,
|
||||
/vite\w*\/dist\/client\/env.mjs/
|
||||
];
|
||||
const CONFIG_NAMES = ["vitest.config", "vite.config"];
|
||||
const WORKSPACES_NAMES = ["vitest.workspace", "vitest.projects"];
|
||||
const CONFIG_EXTENSIONS = [
|
||||
".ts",
|
||||
".mts",
|
||||
".cts",
|
||||
".js",
|
||||
".mjs",
|
||||
".cjs"
|
||||
];
|
||||
const configFiles = CONFIG_NAMES.flatMap((name) => CONFIG_EXTENSIONS.map((ext) => name + ext));
|
||||
const WORKSPACES_EXTENSIONS = [...CONFIG_EXTENSIONS, ".json"];
|
||||
const workspacesFiles = WORKSPACES_NAMES.flatMap((name) => WORKSPACES_EXTENSIONS.map((ext) => name + ext));
|
||||
const globalApis = [
|
||||
"suite",
|
||||
"test",
|
||||
"describe",
|
||||
"it",
|
||||
"chai",
|
||||
"expect",
|
||||
"assert",
|
||||
"expectTypeOf",
|
||||
"assertType",
|
||||
"vitest",
|
||||
"vi",
|
||||
"beforeAll",
|
||||
"afterAll",
|
||||
"beforeEach",
|
||||
"afterEach",
|
||||
"onTestFinished",
|
||||
"onTestFailed"
|
||||
];
|
||||
|
||||
export { API_PATH as A, defaultPort as a, defaultInspectPort as b, configFiles as c, defaultBrowserPort as d, extraInlineDeps as e, globalApis as g, workspacesFiles as w };
|
||||
25
node_modules/vitest/dist/chunks/coverage.DVF1vEu8.js
generated
vendored
Normal file
25
node_modules/vitest/dist/chunks/coverage.DVF1vEu8.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
const CoverageProviderMap = {
|
||||
v8: "@vitest/coverage-v8",
|
||||
istanbul: "@vitest/coverage-istanbul"
|
||||
};
|
||||
async function resolveCoverageProviderModule(options, loader) {
|
||||
if (!options?.enabled || !options.provider) return null;
|
||||
const provider = options.provider;
|
||||
if (provider === "v8" || provider === "istanbul") {
|
||||
let builtInModule = CoverageProviderMap[provider];
|
||||
if (provider === "v8" && loader.isBrowser) builtInModule += "/browser";
|
||||
const { default: coverageModule } = await loader.executeId(builtInModule);
|
||||
if (!coverageModule) throw new Error(`Failed to load ${CoverageProviderMap[provider]}. Default export is missing.`);
|
||||
return coverageModule;
|
||||
}
|
||||
let customProviderModule;
|
||||
try {
|
||||
customProviderModule = await loader.executeId(options.customProviderModule);
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to load custom CoverageProviderModule from ${options.customProviderModule}`, { cause: error });
|
||||
}
|
||||
if (customProviderModule.default == null) throw new Error(`Custom CoverageProviderModule loaded from ${options.customProviderModule} was not the default export`);
|
||||
return customProviderModule.default;
|
||||
}
|
||||
|
||||
export { CoverageProviderMap as C, resolveCoverageProviderModule as r };
|
||||
4350
node_modules/vitest/dist/chunks/coverage.DfSpMS-b.js
generated
vendored
Normal file
4350
node_modules/vitest/dist/chunks/coverage.DfSpMS-b.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
35
node_modules/vitest/dist/chunks/coverage.d.S9RMNXIe.d.ts
generated
vendored
Normal file
35
node_modules/vitest/dist/chunks/coverage.d.S9RMNXIe.d.ts
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
import { ModuleExecutionInfo } from 'vite-node/client';
|
||||
|
||||
interface RuntimeCoverageModuleLoader {
|
||||
executeId: (id: string) => Promise<{
|
||||
default: RuntimeCoverageProviderModule
|
||||
}>;
|
||||
isBrowser?: boolean;
|
||||
moduleExecutionInfo?: ModuleExecutionInfo;
|
||||
}
|
||||
interface RuntimeCoverageProviderModule {
|
||||
/**
|
||||
* Factory for creating a new coverage provider
|
||||
*/
|
||||
getProvider: () => any;
|
||||
/**
|
||||
* Executed before tests are run in the worker thread.
|
||||
*/
|
||||
startCoverage?: (runtimeOptions: {
|
||||
isolate: boolean
|
||||
}) => unknown | Promise<unknown>;
|
||||
/**
|
||||
* Executed on after each run in the worker thread. Possible to return a payload passed to the provider
|
||||
*/
|
||||
takeCoverage?: (runtimeOptions?: {
|
||||
moduleExecutionInfo?: ModuleExecutionInfo
|
||||
}) => unknown | Promise<unknown>;
|
||||
/**
|
||||
* Executed after all tests have been run in the worker thread.
|
||||
*/
|
||||
stopCoverage?: (runtimeOptions: {
|
||||
isolate: boolean
|
||||
}) => unknown | Promise<unknown>;
|
||||
}
|
||||
|
||||
export type { RuntimeCoverageModuleLoader as R, RuntimeCoverageProviderModule as a };
|
||||
640
node_modules/vitest/dist/chunks/creator.GK6I-cL4.js
generated
vendored
Normal file
640
node_modules/vitest/dist/chunks/creator.GK6I-cL4.js
generated
vendored
Normal file
@@ -0,0 +1,640 @@
|
||||
import { existsSync, writeFileSync, readFileSync } from 'node:fs';
|
||||
import { mkdir, writeFile } from 'node:fs/promises';
|
||||
import { resolve, dirname, relative } from 'node:path';
|
||||
import { detectPackageManager, installPackage } from './index.D3XRDfWc.js';
|
||||
import { p as prompt, f as findUp } from './index.X0nbfr6-.js';
|
||||
import { x } from 'tinyexec';
|
||||
import c from 'tinyrainbow';
|
||||
import { c as configFiles } from './constants.DnKduX2e.js';
|
||||
import 'node:process';
|
||||
import 'node:url';
|
||||
import './_commonjsHelpers.BFTU3MAI.js';
|
||||
import 'readline';
|
||||
import 'events';
|
||||
|
||||
const jsxExample = {
|
||||
name: "HelloWorld.jsx",
|
||||
js: `
|
||||
export default function HelloWorld({ name }) {
|
||||
return (
|
||||
<div>
|
||||
<h1>Hello {name}!</h1>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
`,
|
||||
ts: `
|
||||
export default function HelloWorld({ name }: { name: string }) {
|
||||
return (
|
||||
<div>
|
||||
<h1>Hello {name}!</h1>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
`,
|
||||
test: `
|
||||
import { expect, test } from 'vitest'
|
||||
import { render } from '@testing-library/jsx'
|
||||
import HelloWorld from './HelloWorld.jsx'
|
||||
|
||||
test('renders name', async () => {
|
||||
const { getByText } = render(<HelloWorld name="Vitest" />)
|
||||
await expect.element(getByText('Hello Vitest!')).toBeInTheDocument()
|
||||
})
|
||||
`
|
||||
};
|
||||
const vueExample = {
|
||||
name: "HelloWorld.vue",
|
||||
js: `
|
||||
<script setup>
|
||||
defineProps({
|
||||
name: String
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<h1>Hello {{ name }}!</h1>
|
||||
</div>
|
||||
</template>
|
||||
`,
|
||||
ts: `
|
||||
<script setup lang="ts">
|
||||
defineProps<{
|
||||
name: string
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<h1>Hello {{ name }}!</h1>
|
||||
</div>
|
||||
</template>
|
||||
`,
|
||||
test: `
|
||||
import { expect, test } from 'vitest'
|
||||
import { render } from 'vitest-browser-vue'
|
||||
import HelloWorld from './HelloWorld.vue'
|
||||
|
||||
test('renders name', async () => {
|
||||
const { getByText } = render(HelloWorld, {
|
||||
props: { name: 'Vitest' },
|
||||
})
|
||||
await expect.element(getByText('Hello Vitest!')).toBeInTheDocument()
|
||||
})
|
||||
`
|
||||
};
|
||||
const svelteExample = {
|
||||
name: "HelloWorld.svelte",
|
||||
js: `
|
||||
<script>
|
||||
export let name
|
||||
</script>
|
||||
|
||||
<h1>Hello {name}!</h1>
|
||||
`,
|
||||
ts: `
|
||||
<script lang="ts">
|
||||
export let name: string
|
||||
</script>
|
||||
|
||||
<h1>Hello {name}!</h1>
|
||||
`,
|
||||
test: `
|
||||
import { expect, test } from 'vitest'
|
||||
import { render } from 'vitest-browser-svelte'
|
||||
import HelloWorld from './HelloWorld.svelte'
|
||||
|
||||
test('renders name', async () => {
|
||||
const { getByText } = render(HelloWorld, { name: 'Vitest' })
|
||||
await expect.element(getByText('Hello Vitest!')).toBeInTheDocument()
|
||||
})
|
||||
`
|
||||
};
|
||||
const markoExample = {
|
||||
name: "HelloWorld.marko",
|
||||
js: `
|
||||
class {
|
||||
onCreate() {
|
||||
this.state = { name: null }
|
||||
}
|
||||
}
|
||||
|
||||
<h1>Hello \${state.name}!</h1>
|
||||
`,
|
||||
ts: `
|
||||
export interface Input {
|
||||
name: string
|
||||
}
|
||||
|
||||
<h1>Hello \${input.name}!</h1>
|
||||
`,
|
||||
test: `
|
||||
import { expect, test } from 'vitest'
|
||||
import { render } from '@marko/testing-library'
|
||||
import HelloWorld from './HelloWorld.svelte'
|
||||
|
||||
test('renders name', async () => {
|
||||
const { getByText } = await render(HelloWorld, { name: 'Vitest' })
|
||||
const element = getByText('Hello Vitest!')
|
||||
expect(element).toBeInTheDocument()
|
||||
})
|
||||
`
|
||||
};
|
||||
const litExample = {
|
||||
name: "HelloWorld.js",
|
||||
js: `
|
||||
import { html, LitElement } from 'lit'
|
||||
|
||||
export class HelloWorld extends LitElement {
|
||||
static properties = {
|
||||
name: { type: String },
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
this.name = 'World'
|
||||
}
|
||||
|
||||
render() {
|
||||
return html\`<h1>Hello \${this.name}!</h1>\`
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define('hello-world', HelloWorld)
|
||||
`,
|
||||
ts: `
|
||||
import { html, LitElement } from 'lit'
|
||||
import { customElement, property } from 'lit/decorators.js'
|
||||
|
||||
@customElement('hello-world')
|
||||
export class HelloWorld extends LitElement {
|
||||
@property({ type: String })
|
||||
name = 'World'
|
||||
|
||||
render() {
|
||||
return html\`<h1>Hello \${this.name}!</h1>\`
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'hello-world': HelloWorld
|
||||
}
|
||||
}
|
||||
`,
|
||||
test: `
|
||||
import { expect, test } from 'vitest'
|
||||
import { render } from 'vitest-browser-lit'
|
||||
import { html } from 'lit'
|
||||
import './HelloWorld.js'
|
||||
|
||||
test('renders name', async () => {
|
||||
const screen = render(html\`<hello-world name="Vitest"></hello-world>\`)
|
||||
const element = screen.getByText('Hello Vitest!')
|
||||
await expect.element(element).toBeInTheDocument()
|
||||
})
|
||||
`
|
||||
};
|
||||
const vanillaExample = {
|
||||
name: "HelloWorld.js",
|
||||
js: `
|
||||
export default function HelloWorld({ name }) {
|
||||
const parent = document.createElement('div')
|
||||
|
||||
const h1 = document.createElement('h1')
|
||||
h1.textContent = 'Hello ' + name + '!'
|
||||
parent.appendChild(h1)
|
||||
|
||||
return parent
|
||||
}
|
||||
`,
|
||||
ts: `
|
||||
export default function HelloWorld({ name }: { name: string }): HTMLDivElement {
|
||||
const parent = document.createElement('div')
|
||||
|
||||
const h1 = document.createElement('h1')
|
||||
h1.textContent = 'Hello ' + name + '!'
|
||||
parent.appendChild(h1)
|
||||
|
||||
return parent
|
||||
}
|
||||
`,
|
||||
test: `
|
||||
import { expect, test } from 'vitest'
|
||||
import { getByText } from '@testing-library/dom'
|
||||
import HelloWorld from './HelloWorld.js'
|
||||
|
||||
test('renders name', () => {
|
||||
const parent = HelloWorld({ name: 'Vitest' })
|
||||
document.body.appendChild(parent)
|
||||
|
||||
const element = getByText(parent, 'Hello Vitest!')
|
||||
expect(element).toBeInTheDocument()
|
||||
})
|
||||
`
|
||||
};
|
||||
function getExampleTest(framework) {
|
||||
switch (framework) {
|
||||
case "solid": return {
|
||||
...jsxExample,
|
||||
test: jsxExample.test.replace("@testing-library/jsx", `@testing-library/${framework}`)
|
||||
};
|
||||
case "preact":
|
||||
case "react": return {
|
||||
...jsxExample,
|
||||
test: jsxExample.test.replace("@testing-library/jsx", `vitest-browser-${framework}`)
|
||||
};
|
||||
case "vue": return vueExample;
|
||||
case "svelte": return svelteExample;
|
||||
case "lit": return litExample;
|
||||
case "marko": return markoExample;
|
||||
default: return vanillaExample;
|
||||
}
|
||||
}
|
||||
async function generateExampleFiles(framework, lang) {
|
||||
const example = getExampleTest(framework);
|
||||
let fileName = example.name;
|
||||
const folder = resolve(process.cwd(), "vitest-example");
|
||||
const fileContent = example[lang];
|
||||
if (!existsSync(folder)) await mkdir(folder, { recursive: true });
|
||||
const isJSX = fileName.endsWith(".jsx");
|
||||
if (isJSX && lang === "ts") fileName = fileName.replace(".jsx", ".tsx");
|
||||
else if (fileName.endsWith(".js") && lang === "ts") fileName = fileName.replace(".js", ".ts");
|
||||
const filePath = resolve(folder, fileName);
|
||||
const testPath = resolve(folder, `HelloWorld.test.${isJSX ? `${lang}x` : lang}`);
|
||||
writeFileSync(filePath, fileContent.trimStart(), "utf-8");
|
||||
writeFileSync(testPath, example.test.trimStart(), "utf-8");
|
||||
return testPath;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
const log = console.log;
|
||||
function getProviderOptions() {
|
||||
const providers = {
|
||||
playwright: "Playwright relies on Chrome DevTools protocol. Read more: https://playwright.dev",
|
||||
webdriverio: "WebdriverIO uses WebDriver protocol. Read more: https://webdriver.io",
|
||||
preview: "Preview is useful to quickly run your tests in the browser, but not suitable for CI."
|
||||
};
|
||||
return Object.entries(providers).map(([provider, description]) => {
|
||||
return {
|
||||
title: provider,
|
||||
description,
|
||||
value: provider
|
||||
};
|
||||
});
|
||||
}
|
||||
function getBrowserNames(provider) {
|
||||
switch (provider) {
|
||||
case "webdriverio": return [
|
||||
"chrome",
|
||||
"firefox",
|
||||
"edge",
|
||||
"safari"
|
||||
];
|
||||
case "playwright": return [
|
||||
"chromium",
|
||||
"firefox",
|
||||
"webkit"
|
||||
];
|
||||
case "preview": return [
|
||||
"chrome",
|
||||
"firefox",
|
||||
"safari"
|
||||
];
|
||||
}
|
||||
}
|
||||
function getProviderPackageNames(provider) {
|
||||
switch (provider) {
|
||||
case "webdriverio": return {
|
||||
types: "@vitest/browser/providers/webdriverio",
|
||||
pkg: "webdriverio"
|
||||
};
|
||||
case "playwright": return {
|
||||
types: "@vitest/browser/providers/playwright",
|
||||
pkg: "playwright"
|
||||
};
|
||||
case "preview": return {
|
||||
types: "@vitest/browser/matchers",
|
||||
pkg: null
|
||||
};
|
||||
}
|
||||
throw new Error(`Unsupported provider: ${provider}`);
|
||||
}
|
||||
function getFramework() {
|
||||
return [
|
||||
{
|
||||
title: "vanilla",
|
||||
value: "vanilla",
|
||||
description: "No framework, just plain JavaScript or TypeScript."
|
||||
},
|
||||
{
|
||||
title: "vue",
|
||||
value: "vue",
|
||||
description: "\"The Progressive JavaScript Framework\""
|
||||
},
|
||||
{
|
||||
title: "svelte",
|
||||
value: "svelte",
|
||||
description: "\"Svelte: cybernetically enhanced web apps\""
|
||||
},
|
||||
{
|
||||
title: "react",
|
||||
value: "react",
|
||||
description: "\"The library for web and native user interfaces\""
|
||||
},
|
||||
{
|
||||
title: "lit",
|
||||
value: "lit",
|
||||
description: "\"A simple library for building fast, lightweight web components.\""
|
||||
},
|
||||
{
|
||||
title: "preact",
|
||||
value: "preact",
|
||||
description: "\"Fast 3kB alternative to React with the same modern API\""
|
||||
},
|
||||
{
|
||||
title: "solid",
|
||||
value: "solid",
|
||||
description: "\"Simple and performant reactivity for building user interfaces\""
|
||||
},
|
||||
{
|
||||
title: "marko",
|
||||
value: "marko",
|
||||
description: "\"A declarative, HTML-based language that makes building web apps fun\""
|
||||
}
|
||||
];
|
||||
}
|
||||
function getFrameworkTestPackage(framework) {
|
||||
switch (framework) {
|
||||
case "vanilla": return null;
|
||||
case "vue": return "vitest-browser-vue";
|
||||
case "svelte": return "vitest-browser-svelte";
|
||||
case "react": return "vitest-browser-react";
|
||||
case "lit": return "vitest-browser-lit";
|
||||
case "preact": return "vitest-browser-preact";
|
||||
case "solid": return "@solidjs/testing-library";
|
||||
case "marko": return "@marko/testing-library";
|
||||
}
|
||||
throw new Error(`Unsupported framework: ${framework}`);
|
||||
}
|
||||
function getFrameworkPluginPackage(framework) {
|
||||
switch (framework) {
|
||||
case "vue": return "@vitejs/plugin-vue";
|
||||
case "svelte": return "@sveltejs/vite-plugin-svelte";
|
||||
case "react": return "@vitejs/plugin-react";
|
||||
case "preact": return "@preact/preset-vite";
|
||||
case "solid": return "vite-plugin-solid";
|
||||
case "marko": return "@marko/vite";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
async function updateTsConfig(type) {
|
||||
if (type == null) return;
|
||||
const msg = `Add "${c.bold(type)}" to your tsconfig.json "${c.bold("compilerOptions.types")}" field to have better intellisense support.`;
|
||||
log();
|
||||
log(c.yellow("◼"), c.yellow(msg));
|
||||
}
|
||||
function getLanguageOptions() {
|
||||
return [{
|
||||
title: "TypeScript",
|
||||
description: "Use TypeScript.",
|
||||
value: "ts"
|
||||
}, {
|
||||
title: "JavaScript",
|
||||
description: "Use plain JavaScript.",
|
||||
value: "js"
|
||||
}];
|
||||
}
|
||||
async function installPackages(pkgManager, packages) {
|
||||
if (!packages.length) {
|
||||
log(c.green("✔"), c.bold("All packages are already installed."));
|
||||
return;
|
||||
}
|
||||
log(c.cyan("◼"), c.bold("Installing packages..."));
|
||||
log(c.cyan("◼"), packages.join(", "));
|
||||
log();
|
||||
await installPackage(packages, {
|
||||
dev: true,
|
||||
packageManager: pkgManager ?? void 0
|
||||
});
|
||||
}
|
||||
function readPkgJson(path) {
|
||||
if (!existsSync(path)) return null;
|
||||
const content = readFileSync(path, "utf-8");
|
||||
return JSON.parse(content);
|
||||
}
|
||||
function getPossibleDefaults(dependencies) {
|
||||
const provider = getPossibleProvider(dependencies);
|
||||
const framework = getPossibleFramework(dependencies);
|
||||
return {
|
||||
lang: "ts",
|
||||
provider,
|
||||
framework
|
||||
};
|
||||
}
|
||||
function getPossibleFramework(dependencies) {
|
||||
if (dependencies.vue || dependencies["vue-tsc"] || dependencies["@vue/reactivity"]) return "vue";
|
||||
if (dependencies.react || dependencies["react-dom"]) return "react";
|
||||
if (dependencies.svelte || dependencies["@sveltejs/kit"]) return "svelte";
|
||||
if (dependencies.lit || dependencies["lit-html"]) return "lit";
|
||||
if (dependencies.preact) return "preact";
|
||||
if (dependencies["solid-js"] || dependencies["@solidjs/start"]) return "solid";
|
||||
if (dependencies.marko) return "marko";
|
||||
return "vanilla";
|
||||
}
|
||||
function getPossibleProvider(dependencies) {
|
||||
if (dependencies.webdriverio || dependencies["@wdio/cli"] || dependencies["@wdio/config"]) return "webdriverio";
|
||||
// playwright is the default recommendation
|
||||
return "playwright";
|
||||
}
|
||||
function getProviderDocsLink(provider) {
|
||||
switch (provider) {
|
||||
case "playwright": return "https://vitest.dev/guide/browser/playwright";
|
||||
case "webdriverio": return "https://vitest.dev/guide/browser/webdriverio";
|
||||
}
|
||||
}
|
||||
function sort(choices, value) {
|
||||
const index = choices.findIndex((i) => i.value === value);
|
||||
if (index === -1) return choices;
|
||||
const item = choices.splice(index, 1)[0];
|
||||
return [item, ...choices];
|
||||
}
|
||||
function fail() {
|
||||
process.exitCode = 1;
|
||||
}
|
||||
async function generateFrameworkConfigFile(options) {
|
||||
const frameworkImport = options.framework === "svelte" ? `import { svelte } from '${options.frameworkPlugin}'` : `import ${options.framework} from '${options.frameworkPlugin}'`;
|
||||
const configContent = [
|
||||
`import { defineConfig } from 'vitest/config'`,
|
||||
options.frameworkPlugin ? frameworkImport : null,
|
||||
``,
|
||||
"export default defineConfig({",
|
||||
options.frameworkPlugin ? ` plugins: [${options.framework}()],` : null,
|
||||
` test: {`,
|
||||
` browser: {`,
|
||||
` enabled: true,`,
|
||||
` provider: '${options.provider}',`,
|
||||
options.provider !== "preview" && ` // ${getProviderDocsLink(options.provider)}`,
|
||||
` instances: [`,
|
||||
...options.browsers.map((browser) => ` { browser: '${browser}' },`),
|
||||
` ],`,
|
||||
` },`,
|
||||
` },`,
|
||||
`})`,
|
||||
""
|
||||
].filter((t) => typeof t === "string").join("\n");
|
||||
await writeFile(options.configPath, configContent);
|
||||
}
|
||||
async function updatePkgJsonScripts(pkgJsonPath, vitestScript) {
|
||||
if (!existsSync(pkgJsonPath)) {
|
||||
const pkg = { scripts: { "test:browser": vitestScript } };
|
||||
await writeFile(pkgJsonPath, `${JSON.stringify(pkg, null, 2)}\n`, "utf-8");
|
||||
} else {
|
||||
const pkg = JSON.parse(readFileSync(pkgJsonPath, "utf-8"));
|
||||
pkg.scripts = pkg.scripts || {};
|
||||
pkg.scripts["test:browser"] = vitestScript;
|
||||
await writeFile(pkgJsonPath, `${JSON.stringify(pkg, null, 2)}\n`, "utf-8");
|
||||
}
|
||||
log(c.green("✔"), "Added \"test:browser\" script to your package.json.");
|
||||
}
|
||||
function getRunScript(pkgManager) {
|
||||
switch (pkgManager) {
|
||||
case "yarn@berry":
|
||||
case "yarn": return "yarn test:browser";
|
||||
case "pnpm@6":
|
||||
case "pnpm": return "pnpm test:browser";
|
||||
case "bun": return "bun test:browser";
|
||||
default: return "npm run test:browser";
|
||||
}
|
||||
}
|
||||
function getPlaywrightRunArgs(pkgManager) {
|
||||
switch (pkgManager) {
|
||||
case "yarn@berry":
|
||||
case "yarn": return ["yarn", "exec"];
|
||||
case "pnpm@6":
|
||||
case "pnpm": return ["pnpx"];
|
||||
case "bun": return ["bunx"];
|
||||
default: return ["npx"];
|
||||
}
|
||||
}
|
||||
async function create() {
|
||||
log(c.cyan("◼"), "This utility will help you set up a browser testing environment.\n");
|
||||
const pkgJsonPath = resolve(process.cwd(), "package.json");
|
||||
const pkg = readPkgJson(pkgJsonPath) || {};
|
||||
const dependencies = {
|
||||
...pkg.dependencies,
|
||||
...pkg.devDependencies
|
||||
};
|
||||
const defaults = getPossibleDefaults(dependencies);
|
||||
const { lang } = await prompt({
|
||||
type: "select",
|
||||
name: "lang",
|
||||
message: "Choose a language for your tests",
|
||||
choices: sort(getLanguageOptions(), defaults?.lang)
|
||||
});
|
||||
if (!lang) return fail();
|
||||
const { provider } = await prompt({
|
||||
type: "select",
|
||||
name: "provider",
|
||||
message: "Choose a browser provider. Vitest will use its API to control the testing environment",
|
||||
choices: sort(getProviderOptions(), defaults?.provider)
|
||||
});
|
||||
if (!provider) return fail();
|
||||
const { browsers } = await prompt({
|
||||
type: "multiselect",
|
||||
name: "browsers",
|
||||
message: "Choose a browser",
|
||||
choices: getBrowserNames(provider).map((browser) => ({
|
||||
title: browser,
|
||||
value: browser
|
||||
}))
|
||||
});
|
||||
if (!provider) return fail();
|
||||
const { framework } = await prompt({
|
||||
type: "select",
|
||||
name: "framework",
|
||||
message: "Choose your framework",
|
||||
choices: sort(getFramework(), defaults?.framework)
|
||||
});
|
||||
if (!framework) return fail();
|
||||
let installPlaywright = false;
|
||||
if (provider === "playwright") ({installPlaywright} = await prompt({
|
||||
type: "confirm",
|
||||
name: "installPlaywright",
|
||||
message: `Install Playwright browsers (can be done manually via 'pnpm exec playwright install')?`
|
||||
}));
|
||||
if (installPlaywright == null) return fail();
|
||||
const dependenciesToInstall = ["@vitest/browser"];
|
||||
const frameworkPackage = getFrameworkTestPackage(framework);
|
||||
if (frameworkPackage) dependenciesToInstall.push(frameworkPackage);
|
||||
const providerPkg = getProviderPackageNames(provider);
|
||||
if (providerPkg.pkg) dependenciesToInstall.push(providerPkg.pkg);
|
||||
const frameworkPlugin = getFrameworkPluginPackage(framework);
|
||||
if (frameworkPlugin) dependenciesToInstall.push(frameworkPlugin);
|
||||
const pkgManager = await detectPackageManager();
|
||||
log();
|
||||
await installPackages(pkgManager, dependenciesToInstall.filter((pkg) => !dependencies[pkg]));
|
||||
const rootConfig = await findUp(configFiles, { cwd: process.cwd() });
|
||||
let scriptCommand = "vitest";
|
||||
log();
|
||||
if (rootConfig) {
|
||||
const configPath = resolve(dirname(rootConfig), `vitest.browser.config.${lang}`);
|
||||
scriptCommand = `vitest --config=${relative(process.cwd(), configPath)}`;
|
||||
await generateFrameworkConfigFile({
|
||||
configPath,
|
||||
framework,
|
||||
frameworkPlugin,
|
||||
provider,
|
||||
browsers
|
||||
});
|
||||
log(
|
||||
c.green("✔"),
|
||||
"Created a new config file for browser tests:",
|
||||
c.bold(relative(process.cwd(), configPath)),
|
||||
// TODO: Can we modify the config ourselves?
|
||||
"\nSince you already have a Vitest config file, it is recommended to copy the contents of the new file ",
|
||||
"into your existing config located at ",
|
||||
c.bold(relative(process.cwd(), rootConfig))
|
||||
);
|
||||
} else {
|
||||
const configPath = resolve(process.cwd(), `vitest.config.${lang}`);
|
||||
await generateFrameworkConfigFile({
|
||||
configPath,
|
||||
framework,
|
||||
frameworkPlugin,
|
||||
provider,
|
||||
browsers
|
||||
});
|
||||
log(c.green("✔"), "Created a config file for browser tests:", c.bold(relative(process.cwd(), configPath)));
|
||||
}
|
||||
log();
|
||||
await updatePkgJsonScripts(pkgJsonPath, scriptCommand);
|
||||
if (installPlaywright) {
|
||||
log();
|
||||
const [command, ...args] = getPlaywrightRunArgs(pkgManager);
|
||||
const allArgs = [
|
||||
...args,
|
||||
"playwright",
|
||||
"install",
|
||||
"--with-deps"
|
||||
];
|
||||
log(c.cyan("◼"), `Installing Playwright dependencies with \`${c.bold(command)} ${c.bold(allArgs.join(" "))}\`...`);
|
||||
log();
|
||||
await x(command, allArgs, { nodeOptions: { stdio: [
|
||||
"pipe",
|
||||
"inherit",
|
||||
"inherit"
|
||||
] } });
|
||||
}
|
||||
// TODO: can we do this ourselves?
|
||||
if (lang === "ts") await updateTsConfig(providerPkg?.types);
|
||||
log();
|
||||
const exampleTestFile = await generateExampleFiles(framework, lang);
|
||||
log(c.green("✔"), "Created example test file in", c.bold(relative(process.cwd(), exampleTestFile)));
|
||||
log(c.dim(" You can safely delete this file once you have written your own tests."));
|
||||
log();
|
||||
log(c.cyan("◼"), "All done! Run your tests with", c.bold(getRunScript(pkgManager)));
|
||||
}
|
||||
|
||||
export { create };
|
||||
73
node_modules/vitest/dist/chunks/date.Bq6ZW5rf.js
generated
vendored
Normal file
73
node_modules/vitest/dist/chunks/date.Bq6ZW5rf.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
/* Ported from https://github.com/boblauer/MockDate/blob/master/src/mockdate.ts */
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Bob Lauer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
const RealDate = Date;
|
||||
let now = null;
|
||||
class MockDate extends RealDate {
|
||||
constructor(y, m, d, h, M, s, ms) {
|
||||
super();
|
||||
let date;
|
||||
switch (arguments.length) {
|
||||
case 0:
|
||||
if (now !== null) date = new RealDate(now.valueOf());
|
||||
else date = new RealDate();
|
||||
break;
|
||||
case 1:
|
||||
date = new RealDate(y);
|
||||
break;
|
||||
default:
|
||||
d = typeof d === "undefined" ? 1 : d;
|
||||
h = h || 0;
|
||||
M = M || 0;
|
||||
s = s || 0;
|
||||
ms = ms || 0;
|
||||
date = new RealDate(y, m, d, h, M, s, ms);
|
||||
break;
|
||||
}
|
||||
Object.setPrototypeOf(date, MockDate.prototype);
|
||||
return date;
|
||||
}
|
||||
}
|
||||
MockDate.UTC = RealDate.UTC;
|
||||
MockDate.now = function() {
|
||||
return new MockDate().valueOf();
|
||||
};
|
||||
MockDate.parse = function(dateString) {
|
||||
return RealDate.parse(dateString);
|
||||
};
|
||||
MockDate.toString = function() {
|
||||
return RealDate.toString();
|
||||
};
|
||||
function mockDate(date) {
|
||||
const dateObj = new RealDate(date.valueOf());
|
||||
if (Number.isNaN(dateObj.getTime())) throw new TypeError(`mockdate: The time set is an invalid date: ${date}`);
|
||||
// @ts-expect-error global
|
||||
globalThis.Date = MockDate;
|
||||
now = dateObj.valueOf();
|
||||
}
|
||||
function resetDate() {
|
||||
globalThis.Date = RealDate;
|
||||
}
|
||||
|
||||
export { RealDate as R, mockDate as m, resetDate as r };
|
||||
115
node_modules/vitest/dist/chunks/defaults.B7q_naMc.js
generated
vendored
Normal file
115
node_modules/vitest/dist/chunks/defaults.B7q_naMc.js
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
import nodeos__default from 'node:os';
|
||||
import './env.D4Lgay0q.js';
|
||||
import { isCI } from 'std-env';
|
||||
|
||||
const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
|
||||
const defaultExclude = [
|
||||
"**/node_modules/**",
|
||||
"**/dist/**",
|
||||
"**/cypress/**",
|
||||
"**/.{idea,git,cache,output,temp}/**",
|
||||
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*"
|
||||
];
|
||||
const benchmarkConfigDefaults = {
|
||||
include: ["**/*.{bench,benchmark}.?(c|m)[jt]s?(x)"],
|
||||
exclude: defaultExclude,
|
||||
includeSource: [],
|
||||
reporters: ["default"],
|
||||
includeSamples: false
|
||||
};
|
||||
const defaultCoverageExcludes = [
|
||||
"coverage/**",
|
||||
"dist/**",
|
||||
"**/node_modules/**",
|
||||
"**/[.]**",
|
||||
"packages/*/test?(s)/**",
|
||||
"**/*.d.ts",
|
||||
"**/virtual:*",
|
||||
"**/__x00__*",
|
||||
"**/\0*",
|
||||
"cypress/**",
|
||||
"test?(s)/**",
|
||||
"test?(-*).?(c|m)[jt]s?(x)",
|
||||
"**/*{.,-}{test,spec,bench,benchmark}?(-d).?(c|m)[jt]s?(x)",
|
||||
"**/__tests__/**",
|
||||
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*",
|
||||
"**/vitest.{workspace,projects}.[jt]s?(on)",
|
||||
"**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}"
|
||||
];
|
||||
// These are the generic defaults for coverage. Providers may also set some provider specific defaults.
|
||||
const coverageConfigDefaults = {
|
||||
provider: "v8",
|
||||
enabled: false,
|
||||
all: true,
|
||||
clean: true,
|
||||
cleanOnRerun: true,
|
||||
reportsDirectory: "./coverage",
|
||||
exclude: defaultCoverageExcludes,
|
||||
reportOnFailure: false,
|
||||
reporter: [
|
||||
["text", {}],
|
||||
["html", {}],
|
||||
["clover", {}],
|
||||
["json", {}]
|
||||
],
|
||||
extension: [
|
||||
".js",
|
||||
".cjs",
|
||||
".mjs",
|
||||
".ts",
|
||||
".mts",
|
||||
".tsx",
|
||||
".jsx",
|
||||
".vue",
|
||||
".svelte",
|
||||
".marko",
|
||||
".astro"
|
||||
],
|
||||
allowExternal: false,
|
||||
excludeAfterRemap: false,
|
||||
ignoreEmptyLines: true,
|
||||
processingConcurrency: Math.min(20, nodeos__default.availableParallelism?.() ?? nodeos__default.cpus().length)
|
||||
};
|
||||
const fakeTimersDefaults = {
|
||||
loopLimit: 1e4,
|
||||
shouldClearNativeTimers: true
|
||||
};
|
||||
const configDefaults = Object.freeze({
|
||||
allowOnly: !isCI,
|
||||
isolate: true,
|
||||
watch: !isCI && process.stdin.isTTY,
|
||||
globals: false,
|
||||
environment: "node",
|
||||
pool: "forks",
|
||||
clearMocks: false,
|
||||
restoreMocks: false,
|
||||
mockReset: false,
|
||||
unstubGlobals: false,
|
||||
unstubEnvs: false,
|
||||
include: defaultInclude,
|
||||
exclude: defaultExclude,
|
||||
teardownTimeout: 1e4,
|
||||
forceRerunTriggers: ["**/package.json/**", "**/{vitest,vite}.config.*/**"],
|
||||
update: false,
|
||||
reporters: [],
|
||||
silent: false,
|
||||
hideSkippedTests: false,
|
||||
api: false,
|
||||
ui: false,
|
||||
uiBase: "/__vitest__/",
|
||||
open: !isCI,
|
||||
css: { include: [] },
|
||||
coverage: coverageConfigDefaults,
|
||||
fakeTimers: fakeTimersDefaults,
|
||||
maxConcurrency: 5,
|
||||
dangerouslyIgnoreUnhandledErrors: false,
|
||||
typecheck: {
|
||||
checker: "tsc",
|
||||
include: ["**/*.{test,spec}-d.?(c|m)[jt]s?(x)"],
|
||||
exclude: defaultExclude
|
||||
},
|
||||
slowTestThreshold: 300,
|
||||
disableConsoleIntercept: false
|
||||
});
|
||||
|
||||
export { coverageConfigDefaults as a, defaultInclude as b, configDefaults as c, defaultExclude as d, benchmarkConfigDefaults as e };
|
||||
8
node_modules/vitest/dist/chunks/env.D4Lgay0q.js
generated
vendored
Normal file
8
node_modules/vitest/dist/chunks/env.D4Lgay0q.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { isCI } from 'std-env';
|
||||
|
||||
const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions?.deno && !globalThis.window;
|
||||
const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== void 0;
|
||||
const isWindows = (isNode || isDeno) && process.platform === "win32";
|
||||
const isTTY = (isNode || isDeno) && process.stdout?.isTTY && !isCI;
|
||||
|
||||
export { isWindows as a, isTTY as i };
|
||||
119
node_modules/vitest/dist/chunks/environment.d.cL3nLXbE.d.ts
generated
vendored
Normal file
119
node_modules/vitest/dist/chunks/environment.d.cL3nLXbE.d.ts
generated
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
import { happyDomTypes, jsdomTypes } from 'vitest/optional-types.js';
|
||||
|
||||
type Awaitable<T> = T | PromiseLike<T>;
|
||||
type Nullable<T> = T | null | undefined;
|
||||
type Arrayable<T> = T | Array<T>;
|
||||
type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
|
||||
type MutableArray<T extends readonly any[]> = { -readonly [k in keyof T] : T[k] };
|
||||
interface Constructable {
|
||||
new (...args: any[]): any;
|
||||
}
|
||||
type TransformMode = "web" | "ssr";
|
||||
/** @deprecated not used */
|
||||
interface ModuleCache {
|
||||
promise?: Promise<any>;
|
||||
exports?: any;
|
||||
code?: string;
|
||||
}
|
||||
interface AfterSuiteRunMeta {
|
||||
coverage?: unknown;
|
||||
testFiles: string[];
|
||||
transformMode: TransformMode | "browser";
|
||||
projectName?: string;
|
||||
}
|
||||
interface UserConsoleLog {
|
||||
content: string;
|
||||
origin?: string;
|
||||
browser?: boolean;
|
||||
type: "stdout" | "stderr";
|
||||
taskId?: string;
|
||||
time: number;
|
||||
size: number;
|
||||
}
|
||||
interface ModuleGraphData {
|
||||
graph: Record<string, string[]>;
|
||||
externalized: string[];
|
||||
inlined: string[];
|
||||
}
|
||||
interface ProvidedContext {}
|
||||
// These need to be compatible with Tinyrainbow's bg-colors, and CSS's background-color
|
||||
type LabelColor = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white";
|
||||
|
||||
type HappyDOMOptions = Omit<NonNullable<ConstructorParameters<typeof happyDomTypes.Window>[0]>, "console">;
|
||||
|
||||
type JSDOMOptions = ConstructorOptionsOverride & Omit<jsdomTypes.ConstructorOptions, keyof ConstructorOptionsOverride>;
|
||||
interface ConstructorOptionsOverride {
|
||||
/**
|
||||
* The html content for the test.
|
||||
*
|
||||
* @default '<!DOCTYPE html>'
|
||||
*/
|
||||
html?: string | ArrayBufferLike;
|
||||
/**
|
||||
* userAgent affects the value read from navigator.userAgent, as well as the User-Agent header sent while fetching subresources.
|
||||
*
|
||||
* @default `Mozilla/5.0 (${process.platform}) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/${jsdomVersion}`
|
||||
*/
|
||||
userAgent?: string;
|
||||
/**
|
||||
* url sets the value returned by window.location, document.URL, and document.documentURI,
|
||||
* and affects things like resolution of relative URLs within the document
|
||||
* and the same-origin restrictions and referrer used while fetching subresources.
|
||||
*
|
||||
* @default 'http://localhost:3000'.
|
||||
*/
|
||||
url?: string;
|
||||
/**
|
||||
* Enable console?
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
console?: boolean;
|
||||
/**
|
||||
* jsdom does not have the capability to render visual content, and will act like a headless browser by default.
|
||||
* It provides hints to web pages through APIs such as document.hidden that their content is not visible.
|
||||
*
|
||||
* When the `pretendToBeVisual` option is set to `true`, jsdom will pretend that it is rendering and displaying
|
||||
* content.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
pretendToBeVisual?: boolean;
|
||||
/**
|
||||
* Enable CookieJar
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
cookieJar?: boolean;
|
||||
resources?: "usable";
|
||||
}
|
||||
|
||||
interface EnvironmentReturn {
|
||||
teardown: (global: any) => Awaitable<void>;
|
||||
}
|
||||
interface VmEnvironmentReturn {
|
||||
getVmContext: () => {
|
||||
[key: string]: any
|
||||
};
|
||||
teardown: () => Awaitable<void>;
|
||||
}
|
||||
interface Environment {
|
||||
name: string;
|
||||
transformMode: "web" | "ssr";
|
||||
setupVM?: (options: Record<string, any>) => Awaitable<VmEnvironmentReturn>;
|
||||
setup: (global: any, options: Record<string, any>) => Awaitable<EnvironmentReturn>;
|
||||
}
|
||||
interface EnvironmentOptions {
|
||||
/**
|
||||
* jsdom options.
|
||||
*/
|
||||
jsdom?: JSDOMOptions;
|
||||
happyDOM?: HappyDOMOptions;
|
||||
[x: string]: unknown;
|
||||
}
|
||||
interface ResolvedTestEnvironment {
|
||||
environment: Environment;
|
||||
options: Record<string, any> | null;
|
||||
}
|
||||
|
||||
export type { AfterSuiteRunMeta as A, Constructable as C, Environment as E, HappyDOMOptions as H, JSDOMOptions as J, LabelColor as L, ModuleGraphData as M, Nullable as N, ProvidedContext as P, ResolvedTestEnvironment as R, TransformMode as T, UserConsoleLog as U, VmEnvironmentReturn as V, EnvironmentReturn as a, Awaitable as b, Arrayable as c, ArgumentsType as d, MutableArray as e, EnvironmentOptions as f, ModuleCache as g };
|
||||
708
node_modules/vitest/dist/chunks/execute.B7h3T_Hc.js
generated
vendored
Normal file
708
node_modules/vitest/dist/chunks/execute.B7h3T_Hc.js
generated
vendored
Normal file
@@ -0,0 +1,708 @@
|
||||
import fs from 'node:fs';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import vm from 'node:vm';
|
||||
import { processError } from '@vitest/utils/error';
|
||||
import { normalize as normalize$1 } from 'pathe';
|
||||
import { ViteNodeRunner, DEFAULT_REQUEST_STUBS } from 'vite-node/client';
|
||||
import { isInternalRequest, isNodeBuiltin as isNodeBuiltin$1, isPrimitive, toFilePath } from 'vite-node/utils';
|
||||
import { distDir } from '../path.js';
|
||||
import { resolve as resolve$1, isAbsolute as isAbsolute$1 } from 'node:path';
|
||||
import { MockerRegistry, mockObject, RedirectedModule, AutomockedModule } from '@vitest/mocker';
|
||||
import { builtinModules } from 'node:module';
|
||||
import { highlight } from '@vitest/utils';
|
||||
|
||||
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
||||
function normalizeWindowsPath(input = "") {
|
||||
if (!input) return input;
|
||||
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
||||
}
|
||||
const _UNC_REGEX = /^[/\\]{2}/;
|
||||
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
||||
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
||||
const _EXTNAME_RE = /.(\.[^./]+|\.)$/;
|
||||
const normalize = function(path) {
|
||||
if (path.length === 0) return ".";
|
||||
path = normalizeWindowsPath(path);
|
||||
const isUNCPath = path.match(_UNC_REGEX);
|
||||
const isPathAbsolute = isAbsolute(path);
|
||||
const trailingSeparator = path[path.length - 1] === "/";
|
||||
path = normalizeString(path, !isPathAbsolute);
|
||||
if (path.length === 0) {
|
||||
if (isPathAbsolute) return "/";
|
||||
return trailingSeparator ? "./" : ".";
|
||||
}
|
||||
if (trailingSeparator) path += "/";
|
||||
if (_DRIVE_LETTER_RE.test(path)) path += "/";
|
||||
if (isUNCPath) {
|
||||
if (!isPathAbsolute) return `//./${path}`;
|
||||
return `//${path}`;
|
||||
}
|
||||
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
||||
};
|
||||
const join = function(...segments) {
|
||||
let path = "";
|
||||
for (const seg of segments) {
|
||||
if (!seg) continue;
|
||||
if (path.length > 0) {
|
||||
const pathTrailing = path[path.length - 1] === "/";
|
||||
const segLeading = seg[0] === "/";
|
||||
const both = pathTrailing && segLeading;
|
||||
if (both) path += seg.slice(1);
|
||||
else path += pathTrailing || segLeading ? seg : `/${seg}`;
|
||||
} else path += seg;
|
||||
}
|
||||
return normalize(path);
|
||||
};
|
||||
function cwd() {
|
||||
if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
|
||||
return "/";
|
||||
}
|
||||
const resolve = function(...arguments_) {
|
||||
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
||||
let resolvedPath = "";
|
||||
let resolvedAbsolute = false;
|
||||
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
||||
const path = index >= 0 ? arguments_[index] : cwd();
|
||||
if (!path || path.length === 0) continue;
|
||||
resolvedPath = `${path}/${resolvedPath}`;
|
||||
resolvedAbsolute = isAbsolute(path);
|
||||
}
|
||||
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
||||
if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
|
||||
return resolvedPath.length > 0 ? resolvedPath : ".";
|
||||
};
|
||||
function normalizeString(path, allowAboveRoot) {
|
||||
let res = "";
|
||||
let lastSegmentLength = 0;
|
||||
let lastSlash = -1;
|
||||
let dots = 0;
|
||||
let char = null;
|
||||
for (let index = 0; index <= path.length; ++index) {
|
||||
if (index < path.length) char = path[index];
|
||||
else if (char === "/") break;
|
||||
else char = "/";
|
||||
if (char === "/") {
|
||||
if (lastSlash === index - 1 || dots === 1);
|
||||
else if (dots === 2) {
|
||||
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
||||
if (res.length > 2) {
|
||||
const lastSlashIndex = res.lastIndexOf("/");
|
||||
if (lastSlashIndex === -1) {
|
||||
res = "";
|
||||
lastSegmentLength = 0;
|
||||
} else {
|
||||
res = res.slice(0, lastSlashIndex);
|
||||
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
||||
}
|
||||
lastSlash = index;
|
||||
dots = 0;
|
||||
continue;
|
||||
} else if (res.length > 0) {
|
||||
res = "";
|
||||
lastSegmentLength = 0;
|
||||
lastSlash = index;
|
||||
dots = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (allowAboveRoot) {
|
||||
res += res.length > 0 ? "/.." : "..";
|
||||
lastSegmentLength = 2;
|
||||
}
|
||||
} else {
|
||||
if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
|
||||
else res = path.slice(lastSlash + 1, index);
|
||||
lastSegmentLength = index - lastSlash - 1;
|
||||
}
|
||||
lastSlash = index;
|
||||
dots = 0;
|
||||
} else if (char === "." && dots !== -1) ++dots;
|
||||
else dots = -1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
const isAbsolute = function(p) {
|
||||
return _IS_ABSOLUTE_RE.test(p);
|
||||
};
|
||||
const extname = function(p) {
|
||||
if (p === "..") return "";
|
||||
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
||||
return match && match[1] || "";
|
||||
};
|
||||
const dirname = function(p) {
|
||||
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
||||
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
|
||||
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
||||
};
|
||||
const basename = function(p, extension) {
|
||||
const segments = normalizeWindowsPath(p).split("/");
|
||||
let lastSegment = "";
|
||||
for (let i = segments.length - 1; i >= 0; i--) {
|
||||
const val = segments[i];
|
||||
if (val) {
|
||||
lastSegment = val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
||||
};
|
||||
|
||||
const { existsSync, readdirSync, statSync } = fs;
|
||||
function findMockRedirect(root, mockPath, external) {
|
||||
const path = external || mockPath;
|
||||
// it's a node_module alias
|
||||
// all mocks should be inside <root>/__mocks__
|
||||
if (external || isNodeBuiltin(mockPath) || !existsSync(mockPath)) {
|
||||
const mockDirname = dirname(path);
|
||||
const mockFolder = join(root, "__mocks__", mockDirname);
|
||||
if (!existsSync(mockFolder)) return null;
|
||||
const baseOriginal = basename(path);
|
||||
function findFile(mockFolder, baseOriginal) {
|
||||
const files = readdirSync(mockFolder);
|
||||
for (const file of files) {
|
||||
const baseFile = basename(file, extname(file));
|
||||
if (baseFile === baseOriginal) {
|
||||
const path = resolve(mockFolder, file);
|
||||
// if the same name, return the file
|
||||
if (statSync(path).isFile()) return path;
|
||||
else {
|
||||
// find folder/index.{js,ts}
|
||||
const indexFile = findFile(path, "index");
|
||||
if (indexFile) return indexFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return findFile(mockFolder, baseOriginal);
|
||||
}
|
||||
const dir = dirname(path);
|
||||
const baseId = basename(path);
|
||||
const fullPath = resolve(dir, "__mocks__", baseId);
|
||||
return existsSync(fullPath) ? fullPath : null;
|
||||
}
|
||||
const builtins = new Set([
|
||||
...builtinModules,
|
||||
"assert/strict",
|
||||
"diagnostics_channel",
|
||||
"dns/promises",
|
||||
"fs/promises",
|
||||
"path/posix",
|
||||
"path/win32",
|
||||
"readline/promises",
|
||||
"stream/consumers",
|
||||
"stream/promises",
|
||||
"stream/web",
|
||||
"timers/promises",
|
||||
"util/types",
|
||||
"wasi"
|
||||
]);
|
||||
// https://nodejs.org/api/modules.html#built-in-modules-with-mandatory-node-prefix
|
||||
const prefixedBuiltins = new Set([
|
||||
"node:sea",
|
||||
"node:sqlite",
|
||||
"node:test",
|
||||
"node:test/reporters"
|
||||
]);
|
||||
const NODE_BUILTIN_NAMESPACE = "node:";
|
||||
function isNodeBuiltin(id) {
|
||||
if (prefixedBuiltins.has(id)) return true;
|
||||
return builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(NODE_BUILTIN_NAMESPACE.length) : id);
|
||||
}
|
||||
|
||||
const spyModulePath = resolve$1(distDir, "spy.js");
|
||||
class VitestMocker {
|
||||
static pendingIds = [];
|
||||
spyModule;
|
||||
primitives;
|
||||
filterPublicKeys;
|
||||
registries = /* @__PURE__ */ new Map();
|
||||
mockContext = { callstack: null };
|
||||
constructor(executor) {
|
||||
this.executor = executor;
|
||||
const context = this.executor.options.context;
|
||||
if (context) this.primitives = vm.runInContext("({ Object, Error, Function, RegExp, Symbol, Array, Map })", context);
|
||||
else this.primitives = {
|
||||
Object,
|
||||
Error,
|
||||
Function,
|
||||
RegExp,
|
||||
Symbol: globalThis.Symbol,
|
||||
Array,
|
||||
Map
|
||||
};
|
||||
const Symbol = this.primitives.Symbol;
|
||||
this.filterPublicKeys = [
|
||||
"__esModule",
|
||||
Symbol.asyncIterator,
|
||||
Symbol.hasInstance,
|
||||
Symbol.isConcatSpreadable,
|
||||
Symbol.iterator,
|
||||
Symbol.match,
|
||||
Symbol.matchAll,
|
||||
Symbol.replace,
|
||||
Symbol.search,
|
||||
Symbol.split,
|
||||
Symbol.species,
|
||||
Symbol.toPrimitive,
|
||||
Symbol.toStringTag,
|
||||
Symbol.unscopables
|
||||
];
|
||||
}
|
||||
get root() {
|
||||
return this.executor.options.root;
|
||||
}
|
||||
get moduleCache() {
|
||||
return this.executor.moduleCache;
|
||||
}
|
||||
get moduleDirectories() {
|
||||
return this.executor.options.moduleDirectories || [];
|
||||
}
|
||||
async initializeSpyModule() {
|
||||
this.spyModule = await this.executor.executeId(spyModulePath);
|
||||
}
|
||||
getMockerRegistry() {
|
||||
const suite = this.getSuiteFilepath();
|
||||
if (!this.registries.has(suite)) this.registries.set(suite, new MockerRegistry());
|
||||
return this.registries.get(suite);
|
||||
}
|
||||
reset() {
|
||||
this.registries.clear();
|
||||
}
|
||||
deleteCachedItem(id) {
|
||||
const mockId = this.getMockPath(id);
|
||||
if (this.moduleCache.has(mockId)) this.moduleCache.delete(mockId);
|
||||
}
|
||||
isModuleDirectory(path) {
|
||||
return this.moduleDirectories.some((dir) => path.includes(dir));
|
||||
}
|
||||
getSuiteFilepath() {
|
||||
return this.executor.state.filepath || "global";
|
||||
}
|
||||
createError(message, codeFrame) {
|
||||
const Error = this.primitives.Error;
|
||||
const error = new Error(message);
|
||||
Object.assign(error, { codeFrame });
|
||||
return error;
|
||||
}
|
||||
async resolvePath(rawId, importer) {
|
||||
let id;
|
||||
let fsPath;
|
||||
try {
|
||||
[id, fsPath] = await this.executor.originalResolveUrl(rawId, importer);
|
||||
} catch (error) {
|
||||
// it's allowed to mock unresolved modules
|
||||
if (error.code === "ERR_MODULE_NOT_FOUND") {
|
||||
const { id: unresolvedId } = error[Symbol.for("vitest.error.not_found.data")];
|
||||
id = unresolvedId;
|
||||
fsPath = unresolvedId;
|
||||
} else throw error;
|
||||
}
|
||||
// external is node_module or unresolved module
|
||||
// for example, some people mock "vscode" and don't have it installed
|
||||
const external = !isAbsolute$1(fsPath) || this.isModuleDirectory(fsPath) ? rawId : null;
|
||||
return {
|
||||
id,
|
||||
fsPath,
|
||||
external: external ? this.normalizePath(external) : external
|
||||
};
|
||||
}
|
||||
async resolveMocks() {
|
||||
if (!VitestMocker.pendingIds.length) return;
|
||||
await Promise.all(VitestMocker.pendingIds.map(async (mock) => {
|
||||
const { fsPath, external } = await this.resolvePath(mock.id, mock.importer);
|
||||
if (mock.action === "unmock") this.unmockPath(fsPath);
|
||||
if (mock.action === "mock") this.mockPath(mock.id, fsPath, external, mock.type, mock.factory);
|
||||
}));
|
||||
VitestMocker.pendingIds = [];
|
||||
}
|
||||
async callFunctionMock(dep, mock) {
|
||||
const cached = this.moduleCache.get(dep)?.exports;
|
||||
if (cached) return cached;
|
||||
const exports = await mock.resolve();
|
||||
const moduleExports = new Proxy(exports, { get: (target, prop) => {
|
||||
const val = target[prop];
|
||||
// 'then' can exist on non-Promise objects, need nested instanceof check for logic to work
|
||||
if (prop === "then") {
|
||||
if (target instanceof Promise) return target.then.bind(target);
|
||||
} else if (!(prop in target)) {
|
||||
if (this.filterPublicKeys.includes(prop)) return void 0;
|
||||
throw this.createError(`[vitest] No "${String(prop)}" export is defined on the "${mock.raw}" mock. Did you forget to return it from "vi.mock"?
|
||||
If you need to partially mock a module, you can use "importOriginal" helper inside:
|
||||
`, highlight(`vi.mock(import("${mock.raw}"), async (importOriginal) => {
|
||||
const actual = await importOriginal()
|
||||
return {
|
||||
...actual,
|
||||
// your mocked methods
|
||||
}
|
||||
})`));
|
||||
}
|
||||
return val;
|
||||
} });
|
||||
this.moduleCache.set(dep, { exports: moduleExports });
|
||||
return moduleExports;
|
||||
}
|
||||
// public method to avoid circular dependency
|
||||
getMockContext() {
|
||||
return this.mockContext;
|
||||
}
|
||||
// path used to store mocked dependencies
|
||||
getMockPath(dep) {
|
||||
return `mock:${dep}`;
|
||||
}
|
||||
getDependencyMock(id) {
|
||||
const registry = this.getMockerRegistry();
|
||||
return registry.get(id);
|
||||
}
|
||||
normalizePath(path) {
|
||||
return this.moduleCache.normalizePath(path);
|
||||
}
|
||||
resolveMockPath(mockPath, external) {
|
||||
return findMockRedirect(this.root, mockPath, external);
|
||||
}
|
||||
mockObject(object, mockExports = {}, behavior = "automock") {
|
||||
const spyOn = this.spyModule?.spyOn;
|
||||
if (!spyOn) throw this.createError("[vitest] `spyModule` is not defined. This is a Vitest error. Please open a new issue with reproduction.");
|
||||
return mockObject({
|
||||
globalConstructors: this.primitives,
|
||||
spyOn,
|
||||
type: behavior
|
||||
}, object, mockExports);
|
||||
}
|
||||
unmockPath(path) {
|
||||
const registry = this.getMockerRegistry();
|
||||
const id = this.normalizePath(path);
|
||||
registry.delete(id);
|
||||
this.deleteCachedItem(id);
|
||||
}
|
||||
mockPath(originalId, path, external, mockType, factory) {
|
||||
const registry = this.getMockerRegistry();
|
||||
const id = this.normalizePath(path);
|
||||
if (mockType === "manual") registry.register("manual", originalId, id, id, factory);
|
||||
else if (mockType === "autospy") registry.register("autospy", originalId, id, id);
|
||||
else {
|
||||
const redirect = this.resolveMockPath(id, external);
|
||||
if (redirect) registry.register("redirect", originalId, id, id, redirect);
|
||||
else registry.register("automock", originalId, id, id);
|
||||
}
|
||||
// every time the mock is registered, we remove the previous one from the cache
|
||||
this.deleteCachedItem(id);
|
||||
}
|
||||
async importActual(rawId, importer, callstack) {
|
||||
const { id, fsPath } = await this.resolvePath(rawId, importer);
|
||||
const result = await this.executor.cachedRequest(id, fsPath, callstack || [importer]);
|
||||
return result;
|
||||
}
|
||||
async importMock(rawId, importee) {
|
||||
const { id, fsPath, external } = await this.resolvePath(rawId, importee);
|
||||
const normalizedId = this.normalizePath(fsPath);
|
||||
let mock = this.getDependencyMock(normalizedId);
|
||||
if (!mock) {
|
||||
const redirect = this.resolveMockPath(normalizedId, external);
|
||||
if (redirect) mock = new RedirectedModule(rawId, normalizedId, normalizedId, redirect);
|
||||
else mock = new AutomockedModule(rawId, normalizedId, normalizedId);
|
||||
}
|
||||
if (mock.type === "automock" || mock.type === "autospy") {
|
||||
const mod = await this.executor.cachedRequest(id, fsPath, [importee]);
|
||||
return this.mockObject(mod, {}, mock.type);
|
||||
}
|
||||
if (mock.type === "manual") return this.callFunctionMock(fsPath, mock);
|
||||
return this.executor.dependencyRequest(mock.redirect, mock.redirect, [importee]);
|
||||
}
|
||||
async requestWithMock(url, callstack) {
|
||||
const id = this.normalizePath(url);
|
||||
const mock = this.getDependencyMock(id);
|
||||
if (!mock) return;
|
||||
const mockPath = this.getMockPath(id);
|
||||
if (mock.type === "automock" || mock.type === "autospy") {
|
||||
const cache = this.moduleCache.get(mockPath);
|
||||
if (cache.exports) return cache.exports;
|
||||
const exports = {};
|
||||
// Assign the empty exports object early to allow for cycles to work. The object will be filled by mockObject()
|
||||
this.moduleCache.set(mockPath, { exports });
|
||||
const mod = await this.executor.directRequest(url, url, callstack);
|
||||
this.mockObject(mod, exports, mock.type);
|
||||
return exports;
|
||||
}
|
||||
if (mock.type === "manual" && !callstack.includes(mockPath) && !callstack.includes(url)) try {
|
||||
callstack.push(mockPath);
|
||||
// this will not work if user does Promise.all(import(), import())
|
||||
// we can also use AsyncLocalStorage to store callstack, but this won't work in the browser
|
||||
// maybe we should improve mock API in the future?
|
||||
this.mockContext.callstack = callstack;
|
||||
return await this.callFunctionMock(mockPath, mock);
|
||||
} finally {
|
||||
this.mockContext.callstack = null;
|
||||
const indexMock = callstack.indexOf(mockPath);
|
||||
callstack.splice(indexMock, 1);
|
||||
}
|
||||
else if (mock.type === "redirect" && !callstack.includes(mock.redirect)) return mock.redirect;
|
||||
}
|
||||
queueMock(id, importer, factoryOrOptions) {
|
||||
const mockType = getMockType(factoryOrOptions);
|
||||
VitestMocker.pendingIds.push({
|
||||
action: "mock",
|
||||
id,
|
||||
importer,
|
||||
factory: typeof factoryOrOptions === "function" ? factoryOrOptions : void 0,
|
||||
type: mockType
|
||||
});
|
||||
}
|
||||
queueUnmock(id, importer) {
|
||||
VitestMocker.pendingIds.push({
|
||||
action: "unmock",
|
||||
id,
|
||||
importer
|
||||
});
|
||||
}
|
||||
}
|
||||
function getMockType(factoryOrOptions) {
|
||||
if (!factoryOrOptions) return "automock";
|
||||
if (typeof factoryOrOptions === "function") return "manual";
|
||||
return factoryOrOptions.spy ? "autospy" : "automock";
|
||||
}
|
||||
|
||||
const normalizedDistDir = normalize$1(distDir);
|
||||
const { readFileSync } = fs;
|
||||
async function createVitestExecutor(options) {
|
||||
const runner = new VitestExecutor(options);
|
||||
await runner.executeId("/@vite/env");
|
||||
await runner.mocker.initializeSpyModule();
|
||||
return runner;
|
||||
}
|
||||
const externalizeMap = /* @__PURE__ */ new Map();
|
||||
const bareVitestRegexp = /^@?vitest(?:\/|$)/;
|
||||
const dispose = [];
|
||||
function listenForErrors(state) {
|
||||
dispose.forEach((fn) => fn());
|
||||
dispose.length = 0;
|
||||
function catchError(err, type, event) {
|
||||
const worker = state();
|
||||
const listeners = process.listeners(event);
|
||||
// if there is another listener, assume that it's handled by user code
|
||||
// one is Vitest's own listener
|
||||
if (listeners.length > 1) return;
|
||||
const error = processError(err);
|
||||
if (!isPrimitive(error)) {
|
||||
error.VITEST_TEST_NAME = worker.current?.type === "test" ? worker.current.name : void 0;
|
||||
if (worker.filepath) error.VITEST_TEST_PATH = worker.filepath;
|
||||
error.VITEST_AFTER_ENV_TEARDOWN = worker.environmentTeardownRun;
|
||||
}
|
||||
state().rpc.onUnhandledError(error, type);
|
||||
}
|
||||
const uncaughtException = (e) => catchError(e, "Uncaught Exception", "uncaughtException");
|
||||
const unhandledRejection = (e) => catchError(e, "Unhandled Rejection", "unhandledRejection");
|
||||
process.on("uncaughtException", uncaughtException);
|
||||
process.on("unhandledRejection", unhandledRejection);
|
||||
dispose.push(() => {
|
||||
process.off("uncaughtException", uncaughtException);
|
||||
process.off("unhandledRejection", unhandledRejection);
|
||||
});
|
||||
}
|
||||
const relativeIds = {};
|
||||
function getVitestImport(id, state) {
|
||||
if (externalizeMap.has(id)) return { externalize: externalizeMap.get(id) };
|
||||
// always externalize Vitest because we import from there before running tests
|
||||
// so we already have it cached by Node.js
|
||||
const root = state().config.root;
|
||||
const relativeRoot = relativeIds[root] ?? (relativeIds[root] = normalizedDistDir.slice(root.length));
|
||||
if (id.includes(distDir) || id.includes(normalizedDistDir) || relativeRoot && relativeRoot !== "/" && id.startsWith(relativeRoot)) {
|
||||
const { path } = toFilePath(id, root);
|
||||
const externalize = pathToFileURL(path).toString();
|
||||
externalizeMap.set(id, externalize);
|
||||
return { externalize };
|
||||
}
|
||||
if (bareVitestRegexp.test(id)) {
|
||||
externalizeMap.set(id, id);
|
||||
return { externalize: id };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
async function startVitestExecutor(options) {
|
||||
const state = () => globalThis.__vitest_worker__ || options.state;
|
||||
const rpc = () => state().rpc;
|
||||
process.exit = (code = process.exitCode || 0) => {
|
||||
throw new Error(`process.exit unexpectedly called with "${code}"`);
|
||||
};
|
||||
listenForErrors(state);
|
||||
const getTransformMode = () => {
|
||||
return state().environment.transformMode ?? "ssr";
|
||||
};
|
||||
return await createVitestExecutor({
|
||||
async fetchModule(id) {
|
||||
const vitest = getVitestImport(id, state);
|
||||
if (vitest) return vitest;
|
||||
const result = await rpc().fetch(id, getTransformMode());
|
||||
if (result.id && !result.externalize) {
|
||||
const code = readFileSync(result.id, "utf-8");
|
||||
return { code };
|
||||
}
|
||||
return result;
|
||||
},
|
||||
resolveId(id, importer) {
|
||||
return rpc().resolveId(id, importer, getTransformMode());
|
||||
},
|
||||
get moduleCache() {
|
||||
return state().moduleCache;
|
||||
},
|
||||
get moduleExecutionInfo() {
|
||||
return state().moduleExecutionInfo;
|
||||
},
|
||||
get interopDefault() {
|
||||
return state().config.deps.interopDefault;
|
||||
},
|
||||
get moduleDirectories() {
|
||||
return state().config.deps.moduleDirectories;
|
||||
},
|
||||
get root() {
|
||||
return state().config.root;
|
||||
},
|
||||
get base() {
|
||||
return state().config.base;
|
||||
},
|
||||
...options
|
||||
});
|
||||
}
|
||||
function updateStyle(id, css) {
|
||||
if (typeof document === "undefined") return;
|
||||
const element = document.querySelector(`[data-vite-dev-id="${id}"]`);
|
||||
if (element) {
|
||||
element.textContent = css;
|
||||
return;
|
||||
}
|
||||
const head = document.querySelector("head");
|
||||
const style = document.createElement("style");
|
||||
style.setAttribute("type", "text/css");
|
||||
style.setAttribute("data-vite-dev-id", id);
|
||||
style.textContent = css;
|
||||
head?.appendChild(style);
|
||||
}
|
||||
function removeStyle(id) {
|
||||
if (typeof document === "undefined") return;
|
||||
const sheet = document.querySelector(`[data-vite-dev-id="${id}"]`);
|
||||
if (sheet) document.head.removeChild(sheet);
|
||||
}
|
||||
function getDefaultRequestStubs(context) {
|
||||
if (!context) {
|
||||
const clientStub = {
|
||||
...DEFAULT_REQUEST_STUBS["@vite/client"],
|
||||
updateStyle,
|
||||
removeStyle
|
||||
};
|
||||
return {
|
||||
"/@vite/client": clientStub,
|
||||
"@vite/client": clientStub
|
||||
};
|
||||
}
|
||||
const clientStub = vm.runInContext(`(defaultClient) => ({ ...defaultClient, updateStyle: ${updateStyle.toString()}, removeStyle: ${removeStyle.toString()} })`, context)(DEFAULT_REQUEST_STUBS["@vite/client"]);
|
||||
return {
|
||||
"/@vite/client": clientStub,
|
||||
"@vite/client": clientStub
|
||||
};
|
||||
}
|
||||
class VitestExecutor extends ViteNodeRunner {
|
||||
mocker;
|
||||
externalModules;
|
||||
primitives;
|
||||
constructor(options) {
|
||||
super({
|
||||
...options,
|
||||
interopDefault: options.context ? false : options.interopDefault
|
||||
});
|
||||
this.options = options;
|
||||
this.mocker = new VitestMocker(this);
|
||||
if (!options.context) {
|
||||
Object.defineProperty(globalThis, "__vitest_mocker__", {
|
||||
value: this.mocker,
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
||||
this.primitives = {
|
||||
Object,
|
||||
Reflect,
|
||||
Symbol
|
||||
};
|
||||
} else if (options.externalModulesExecutor) {
|
||||
this.primitives = vm.runInContext("({ Object, Reflect, Symbol })", options.context);
|
||||
this.externalModules = options.externalModulesExecutor;
|
||||
} else throw new Error("When context is provided, externalModulesExecutor must be provided as well.");
|
||||
}
|
||||
getContextPrimitives() {
|
||||
return this.primitives;
|
||||
}
|
||||
get state() {
|
||||
// @ts-expect-error injected untyped global
|
||||
return globalThis.__vitest_worker__ || this.options.state;
|
||||
}
|
||||
get moduleExecutionInfo() {
|
||||
return this.options.moduleExecutionInfo;
|
||||
}
|
||||
shouldResolveId(id, _importee) {
|
||||
if (isInternalRequest(id) || id.startsWith("data:")) return false;
|
||||
const transformMode = this.state.environment?.transformMode ?? "ssr";
|
||||
// do not try and resolve node builtins in Node
|
||||
// import('url') returns Node internal even if 'url' package is installed
|
||||
return transformMode === "ssr" ? !isNodeBuiltin$1(id) : !id.startsWith("node:");
|
||||
}
|
||||
async originalResolveUrl(id, importer) {
|
||||
return super.resolveUrl(id, importer);
|
||||
}
|
||||
async resolveUrl(id, importer) {
|
||||
if (VitestMocker.pendingIds.length) await this.mocker.resolveMocks();
|
||||
if (importer && importer.startsWith("mock:")) importer = importer.slice(5);
|
||||
try {
|
||||
return await super.resolveUrl(id, importer);
|
||||
} catch (error) {
|
||||
if (error.code === "ERR_MODULE_NOT_FOUND") {
|
||||
const { id } = error[Symbol.for("vitest.error.not_found.data")];
|
||||
const path = this.mocker.normalizePath(id);
|
||||
const mock = this.mocker.getDependencyMock(path);
|
||||
if (mock !== void 0) return [id, id];
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
async runModule(context, transformed) {
|
||||
const vmContext = this.options.context;
|
||||
if (!vmContext || !this.externalModules) return super.runModule(context, transformed);
|
||||
// add 'use strict' since ESM enables it by default
|
||||
const codeDefinition = `'use strict';async (${Object.keys(context).join(",")})=>{{`;
|
||||
const code = `${codeDefinition}${transformed}\n}}`;
|
||||
const options = {
|
||||
filename: context.__filename,
|
||||
lineOffset: 0,
|
||||
columnOffset: -codeDefinition.length
|
||||
};
|
||||
const finishModuleExecutionInfo = this.startCalculateModuleExecutionInfo(options.filename, codeDefinition.length);
|
||||
try {
|
||||
const fn = vm.runInContext(code, vmContext, {
|
||||
...options,
|
||||
importModuleDynamically: this.externalModules.importModuleDynamically
|
||||
});
|
||||
await fn(...Object.values(context));
|
||||
} finally {
|
||||
this.options.moduleExecutionInfo?.set(options.filename, finishModuleExecutionInfo());
|
||||
}
|
||||
}
|
||||
async importExternalModule(path) {
|
||||
if (this.externalModules) return this.externalModules.import(path);
|
||||
return super.importExternalModule(path);
|
||||
}
|
||||
async dependencyRequest(id, fsPath, callstack) {
|
||||
const mocked = await this.mocker.requestWithMock(fsPath, callstack);
|
||||
if (typeof mocked === "string") return super.dependencyRequest(mocked, mocked, callstack);
|
||||
if (mocked && typeof mocked === "object") return mocked;
|
||||
return super.dependencyRequest(id, fsPath, callstack);
|
||||
}
|
||||
prepareContext(context) {
|
||||
// support `import.meta.vitest` for test entry
|
||||
if (this.state.filepath && normalize$1(this.state.filepath) === normalize$1(context.__filename)) {
|
||||
const globalNamespace = this.options.context || globalThis;
|
||||
Object.defineProperty(context.__vite_ssr_import_meta__, "vitest", { get: () => globalNamespace.__vitest_index__ });
|
||||
}
|
||||
if (this.options.context && this.externalModules) context.require = this.externalModules.createRequire(context.__filename);
|
||||
return context;
|
||||
}
|
||||
}
|
||||
|
||||
export { VitestExecutor as V, getDefaultRequestStubs as g, startVitestExecutor as s };
|
||||
72
node_modules/vitest/dist/chunks/git.BVQ8w_Sw.js
generated
vendored
Normal file
72
node_modules/vitest/dist/chunks/git.BVQ8w_Sw.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
import { resolve } from 'pathe';
|
||||
import { x } from 'tinyexec';
|
||||
|
||||
class VitestGit {
|
||||
root;
|
||||
constructor(cwd) {
|
||||
this.cwd = cwd;
|
||||
}
|
||||
async resolveFilesWithGitCommand(args) {
|
||||
let result;
|
||||
try {
|
||||
result = await x("git", args, { nodeOptions: { cwd: this.root } });
|
||||
} catch (e) {
|
||||
e.message = e.stderr;
|
||||
throw e;
|
||||
}
|
||||
return result.stdout.split("\n").filter((s) => s !== "").map((changedPath) => resolve(this.root, changedPath));
|
||||
}
|
||||
async findChangedFiles(options) {
|
||||
const root = await this.getRoot(this.cwd);
|
||||
if (!root) return null;
|
||||
this.root = root;
|
||||
const changedSince = options.changedSince;
|
||||
if (typeof changedSince === "string") {
|
||||
const [committed, staged, unstaged] = await Promise.all([
|
||||
this.getFilesSince(changedSince),
|
||||
this.getStagedFiles(),
|
||||
this.getUnstagedFiles()
|
||||
]);
|
||||
return [
|
||||
...committed,
|
||||
...staged,
|
||||
...unstaged
|
||||
];
|
||||
}
|
||||
const [staged, unstaged] = await Promise.all([this.getStagedFiles(), this.getUnstagedFiles()]);
|
||||
return [...staged, ...unstaged];
|
||||
}
|
||||
getFilesSince(hash) {
|
||||
return this.resolveFilesWithGitCommand([
|
||||
"diff",
|
||||
"--name-only",
|
||||
`${hash}...HEAD`
|
||||
]);
|
||||
}
|
||||
getStagedFiles() {
|
||||
return this.resolveFilesWithGitCommand([
|
||||
"diff",
|
||||
"--cached",
|
||||
"--name-only"
|
||||
]);
|
||||
}
|
||||
getUnstagedFiles() {
|
||||
return this.resolveFilesWithGitCommand([
|
||||
"ls-files",
|
||||
"--other",
|
||||
"--modified",
|
||||
"--exclude-standard"
|
||||
]);
|
||||
}
|
||||
async getRoot(cwd) {
|
||||
const args = ["rev-parse", "--show-cdup"];
|
||||
try {
|
||||
const result = await x("git", args, { nodeOptions: { cwd } });
|
||||
return resolve(cwd, result.stdout.trim());
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { VitestGit };
|
||||
136
node_modules/vitest/dist/chunks/global.d.MAmajcmJ.d.ts
generated
vendored
Normal file
136
node_modules/vitest/dist/chunks/global.d.MAmajcmJ.d.ts
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
import { PromisifyAssertion, Tester, ExpectStatic } from '@vitest/expect';
|
||||
import { Plugin } from '@vitest/pretty-format';
|
||||
import { SnapshotState } from '@vitest/snapshot';
|
||||
import { B as BenchmarkResult } from './benchmark.d.BwvBVTda.js';
|
||||
import { U as UserConsoleLog } from './environment.d.cL3nLXbE.js';
|
||||
|
||||
type RawErrsMap = Map<string, TscErrorInfo[]>;
|
||||
interface TscErrorInfo {
|
||||
filePath: string;
|
||||
errCode: number;
|
||||
errMsg: string;
|
||||
line: number;
|
||||
column: number;
|
||||
}
|
||||
interface CollectLineNumbers {
|
||||
target: number;
|
||||
next: number;
|
||||
prev?: number;
|
||||
}
|
||||
type CollectLines = { [key in keyof CollectLineNumbers] : string };
|
||||
interface RootAndTarget {
|
||||
root: string;
|
||||
targetAbsPath: string;
|
||||
}
|
||||
type Context = RootAndTarget & {
|
||||
rawErrsMap: RawErrsMap
|
||||
openedDirs: Set<string>
|
||||
lastActivePath?: string
|
||||
};
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line ts/no-namespace
|
||||
namespace Chai {
|
||||
interface Assertion {
|
||||
containSubset: (expected: any) => Assertion;
|
||||
}
|
||||
interface Assert {
|
||||
containSubset: (val: any, exp: any, msg?: string) => void;
|
||||
}
|
||||
}
|
||||
}
|
||||
interface SnapshotMatcher<T> {
|
||||
<U extends { [P in keyof T] : any }>(snapshot: Partial<U>, hint?: string): void;
|
||||
(hint?: string): void;
|
||||
}
|
||||
interface InlineSnapshotMatcher<T> {
|
||||
<U extends { [P in keyof T] : any }>(properties: Partial<U>, snapshot?: string, hint?: string): void;
|
||||
(hint?: string): void;
|
||||
}
|
||||
declare module "@vitest/expect" {
|
||||
interface MatcherState {
|
||||
environment: string;
|
||||
snapshotState: SnapshotState;
|
||||
}
|
||||
interface ExpectPollOptions {
|
||||
interval?: number;
|
||||
timeout?: number;
|
||||
message?: string;
|
||||
}
|
||||
interface ExpectStatic {
|
||||
unreachable: (message?: string) => never;
|
||||
soft: <T>(actual: T, message?: string) => Assertion<T>;
|
||||
poll: <T>(actual: () => T, options?: ExpectPollOptions) => PromisifyAssertion<Awaited<T>>;
|
||||
addEqualityTesters: (testers: Array<Tester>) => void;
|
||||
assertions: (expected: number) => void;
|
||||
hasAssertions: () => void;
|
||||
addSnapshotSerializer: (plugin: Plugin) => void;
|
||||
}
|
||||
interface Assertion<T> {
|
||||
// Snapshots are extended in @vitest/snapshot and are not part of @vitest/expect
|
||||
matchSnapshot: SnapshotMatcher<T>;
|
||||
toMatchSnapshot: SnapshotMatcher<T>;
|
||||
toMatchInlineSnapshot: InlineSnapshotMatcher<T>;
|
||||
/**
|
||||
* Checks that an error thrown by a function matches a previously recorded snapshot.
|
||||
*
|
||||
* @param hint - Optional custom error message.
|
||||
*
|
||||
* @example
|
||||
* expect(functionWithError).toThrowErrorMatchingSnapshot();
|
||||
*/
|
||||
toThrowErrorMatchingSnapshot: (hint?: string) => void;
|
||||
/**
|
||||
* Checks that an error thrown by a function matches an inline snapshot within the test file.
|
||||
* Useful for keeping snapshots close to the test code.
|
||||
*
|
||||
* @param snapshot - Optional inline snapshot string to match.
|
||||
* @param hint - Optional custom error message.
|
||||
*
|
||||
* @example
|
||||
* const throwError = () => { throw new Error('Error occurred') };
|
||||
* expect(throwError).toThrowErrorMatchingInlineSnapshot(`"Error occurred"`);
|
||||
*/
|
||||
toThrowErrorMatchingInlineSnapshot: (snapshot?: string, hint?: string) => void;
|
||||
/**
|
||||
* Compares the received value to a snapshot saved in a specified file.
|
||||
* Useful for cases where snapshot content is large or needs to be shared across tests.
|
||||
*
|
||||
* @param filepath - Path to the snapshot file.
|
||||
* @param hint - Optional custom error message.
|
||||
*
|
||||
* @example
|
||||
* await expect(largeData).toMatchFileSnapshot('path/to/snapshot.json');
|
||||
*/
|
||||
toMatchFileSnapshot: (filepath: string, hint?: string) => Promise<void>;
|
||||
}
|
||||
}
|
||||
declare module "@vitest/runner" {
|
||||
interface TestContext {
|
||||
/**
|
||||
* `expect` instance bound to the current test.
|
||||
*
|
||||
* This API is useful for running snapshot tests concurrently because global expect cannot track them.
|
||||
*/
|
||||
readonly expect: ExpectStatic;
|
||||
/** @internal */
|
||||
_local: boolean;
|
||||
}
|
||||
interface TaskMeta {
|
||||
typecheck?: boolean;
|
||||
benchmark?: boolean;
|
||||
failScreenshotPath?: string;
|
||||
}
|
||||
interface File {
|
||||
prepareDuration?: number;
|
||||
environmentLoad?: number;
|
||||
}
|
||||
interface TaskBase {
|
||||
logs?: UserConsoleLog[];
|
||||
}
|
||||
interface TaskResult {
|
||||
benchmark?: BenchmarkResult;
|
||||
}
|
||||
}
|
||||
|
||||
export type { CollectLineNumbers as C, RawErrsMap as R, TscErrorInfo as T, CollectLines as a, RootAndTarget as b, Context as c };
|
||||
26
node_modules/vitest/dist/chunks/globals.DEHgCU4V.js
generated
vendored
Normal file
26
node_modules/vitest/dist/chunks/globals.DEHgCU4V.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import { g as globalApis } from './constants.DnKduX2e.js';
|
||||
import { V as VitestIndex } from './index.CdQS2e2Q.js';
|
||||
import './vi.bdSIJ99Y.js';
|
||||
import '@vitest/expect';
|
||||
import '@vitest/runner';
|
||||
import '@vitest/runner/utils';
|
||||
import 'chai';
|
||||
import './utils.XdZDrNZV.js';
|
||||
import '@vitest/utils';
|
||||
import './_commonjsHelpers.BFTU3MAI.js';
|
||||
import '@vitest/snapshot';
|
||||
import '@vitest/utils/error';
|
||||
import '@vitest/spy';
|
||||
import '@vitest/utils/source-map';
|
||||
import './date.Bq6ZW5rf.js';
|
||||
import './benchmark.CYdenmiT.js';
|
||||
import 'expect-type';
|
||||
|
||||
function registerApiGlobally() {
|
||||
globalApis.forEach((api) => {
|
||||
// @ts-expect-error I know what I am doing :P
|
||||
globalThis[api] = VitestIndex[api];
|
||||
});
|
||||
}
|
||||
|
||||
export { registerApiGlobally };
|
||||
157
node_modules/vitest/dist/chunks/index.B521nVV-.js
generated
vendored
Normal file
157
node_modules/vitest/dist/chunks/index.B521nVV-.js
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
const TYPE_REQUEST = "q";
|
||||
const TYPE_RESPONSE = "s";
|
||||
const DEFAULT_TIMEOUT = 6e4;
|
||||
function defaultSerialize(i) {
|
||||
return i;
|
||||
}
|
||||
const defaultDeserialize = defaultSerialize;
|
||||
const { clearTimeout, setTimeout } = globalThis;
|
||||
const random = Math.random.bind(Math);
|
||||
function createBirpc(functions, options) {
|
||||
const {
|
||||
post,
|
||||
on,
|
||||
off = () => {
|
||||
},
|
||||
eventNames = [],
|
||||
serialize = defaultSerialize,
|
||||
deserialize = defaultDeserialize,
|
||||
resolver,
|
||||
bind = "rpc",
|
||||
timeout = DEFAULT_TIMEOUT
|
||||
} = options;
|
||||
const rpcPromiseMap = /* @__PURE__ */ new Map();
|
||||
let _promise;
|
||||
let closed = false;
|
||||
const rpc = new Proxy({}, {
|
||||
get(_, method) {
|
||||
if (method === "$functions")
|
||||
return functions;
|
||||
if (method === "$close")
|
||||
return close;
|
||||
if (method === "$closed")
|
||||
return closed;
|
||||
if (method === "then" && !eventNames.includes("then") && !("then" in functions))
|
||||
return undefined;
|
||||
const sendEvent = (...args) => {
|
||||
post(serialize({ m: method, a: args, t: TYPE_REQUEST }));
|
||||
};
|
||||
if (eventNames.includes(method)) {
|
||||
sendEvent.asEvent = sendEvent;
|
||||
return sendEvent;
|
||||
}
|
||||
const sendCall = async (...args) => {
|
||||
if (closed)
|
||||
throw new Error(`[birpc] rpc is closed, cannot call "${method}"`);
|
||||
if (_promise) {
|
||||
try {
|
||||
await _promise;
|
||||
} finally {
|
||||
_promise = undefined;
|
||||
}
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
const id = nanoid();
|
||||
let timeoutId;
|
||||
if (timeout >= 0) {
|
||||
timeoutId = setTimeout(() => {
|
||||
try {
|
||||
const handleResult = options.onTimeoutError?.(method, args);
|
||||
if (handleResult !== true)
|
||||
throw new Error(`[birpc] timeout on calling "${method}"`);
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
rpcPromiseMap.delete(id);
|
||||
}, timeout);
|
||||
if (typeof timeoutId === "object")
|
||||
timeoutId = timeoutId.unref?.();
|
||||
}
|
||||
rpcPromiseMap.set(id, { resolve, reject, timeoutId, method });
|
||||
post(serialize({ m: method, a: args, i: id, t: "q" }));
|
||||
});
|
||||
};
|
||||
sendCall.asEvent = sendEvent;
|
||||
return sendCall;
|
||||
}
|
||||
});
|
||||
function close(error) {
|
||||
closed = true;
|
||||
rpcPromiseMap.forEach(({ reject, method }) => {
|
||||
reject(error || new Error(`[birpc] rpc is closed, cannot call "${method}"`));
|
||||
});
|
||||
rpcPromiseMap.clear();
|
||||
off(onMessage);
|
||||
}
|
||||
async function onMessage(data, ...extra) {
|
||||
let msg;
|
||||
try {
|
||||
msg = deserialize(data);
|
||||
} catch (e) {
|
||||
if (options.onGeneralError?.(e) !== true)
|
||||
throw e;
|
||||
return;
|
||||
}
|
||||
if (msg.t === TYPE_REQUEST) {
|
||||
const { m: method, a: args } = msg;
|
||||
let result, error;
|
||||
const fn = resolver ? resolver(method, functions[method]) : functions[method];
|
||||
if (!fn) {
|
||||
error = new Error(`[birpc] function "${method}" not found`);
|
||||
} else {
|
||||
try {
|
||||
result = await fn.apply(bind === "rpc" ? rpc : functions, args);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
}
|
||||
if (msg.i) {
|
||||
if (error && options.onError)
|
||||
options.onError(error, method, args);
|
||||
if (error && options.onFunctionError) {
|
||||
if (options.onFunctionError(error, method, args) === true)
|
||||
return;
|
||||
}
|
||||
if (!error) {
|
||||
try {
|
||||
post(serialize({ t: TYPE_RESPONSE, i: msg.i, r: result }), ...extra);
|
||||
return;
|
||||
} catch (e) {
|
||||
error = e;
|
||||
if (options.onGeneralError?.(e, method, args) !== true)
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
try {
|
||||
post(serialize({ t: TYPE_RESPONSE, i: msg.i, e: error }), ...extra);
|
||||
} catch (e) {
|
||||
if (options.onGeneralError?.(e, method, args) !== true)
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const { i: ack, r: result, e: error } = msg;
|
||||
const promise = rpcPromiseMap.get(ack);
|
||||
if (promise) {
|
||||
clearTimeout(promise.timeoutId);
|
||||
if (error)
|
||||
promise.reject(error);
|
||||
else
|
||||
promise.resolve(result);
|
||||
}
|
||||
rpcPromiseMap.delete(ack);
|
||||
}
|
||||
}
|
||||
_promise = on(onMessage);
|
||||
return rpc;
|
||||
}
|
||||
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
||||
function nanoid(size = 21) {
|
||||
let id = "";
|
||||
let i = size;
|
||||
while (i--)
|
||||
id += urlAlphabet[random() * 64 | 0];
|
||||
return id;
|
||||
}
|
||||
|
||||
export { createBirpc as c };
|
||||
231
node_modules/vitest/dist/chunks/index.BCWujgDG.js
generated
vendored
Normal file
231
node_modules/vitest/dist/chunks/index.BCWujgDG.js
generated
vendored
Normal file
@@ -0,0 +1,231 @@
|
||||
import fs from 'node:fs';
|
||||
import { getTasks, getFullName, getTests } from '@vitest/runner/utils';
|
||||
import * as pathe from 'pathe';
|
||||
import c from 'tinyrainbow';
|
||||
import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName } from './index.VByaPkjc.js';
|
||||
import { stripVTControlCharacters } from 'node:util';
|
||||
import { notNullish } from '@vitest/utils';
|
||||
|
||||
function createBenchmarkJsonReport(files) {
|
||||
const report = { files: [] };
|
||||
for (const file of files) {
|
||||
const groups = [];
|
||||
for (const task of getTasks(file)) if (task?.type === "suite") {
|
||||
const benchmarks = [];
|
||||
for (const t of task.tasks) {
|
||||
const benchmark = t.meta.benchmark && t.result?.benchmark;
|
||||
if (benchmark) benchmarks.push({
|
||||
id: t.id,
|
||||
...benchmark,
|
||||
samples: []
|
||||
});
|
||||
}
|
||||
if (benchmarks.length) groups.push({
|
||||
fullName: getFullName(task, " > "),
|
||||
benchmarks
|
||||
});
|
||||
}
|
||||
report.files.push({
|
||||
filepath: file.filepath,
|
||||
groups
|
||||
});
|
||||
}
|
||||
return report;
|
||||
}
|
||||
function flattenFormattedBenchmarkReport(report) {
|
||||
const flat = {};
|
||||
for (const file of report.files) for (const group of file.groups) for (const t of group.benchmarks) flat[t.id] = t;
|
||||
return flat;
|
||||
}
|
||||
|
||||
const outputMap = /* @__PURE__ */ new WeakMap();
|
||||
function formatNumber(number) {
|
||||
const res = String(number.toFixed(number < 100 ? 4 : 2)).split(".");
|
||||
return res[0].replace(/(?=(?:\d{3})+$)\B/g, ",") + (res[1] ? `.${res[1]}` : "");
|
||||
}
|
||||
const tableHead = [
|
||||
"name",
|
||||
"hz",
|
||||
"min",
|
||||
"max",
|
||||
"mean",
|
||||
"p75",
|
||||
"p99",
|
||||
"p995",
|
||||
"p999",
|
||||
"rme",
|
||||
"samples"
|
||||
];
|
||||
function renderBenchmarkItems(result) {
|
||||
return [
|
||||
result.name,
|
||||
formatNumber(result.hz || 0),
|
||||
formatNumber(result.min || 0),
|
||||
formatNumber(result.max || 0),
|
||||
formatNumber(result.mean || 0),
|
||||
formatNumber(result.p75 || 0),
|
||||
formatNumber(result.p99 || 0),
|
||||
formatNumber(result.p995 || 0),
|
||||
formatNumber(result.p999 || 0),
|
||||
`±${(result.rme || 0).toFixed(2)}%`,
|
||||
(result.sampleCount || 0).toString()
|
||||
];
|
||||
}
|
||||
function computeColumnWidths(results) {
|
||||
const rows = [tableHead, ...results.map((v) => renderBenchmarkItems(v))];
|
||||
return Array.from(tableHead, (_, i) => Math.max(...rows.map((row) => stripVTControlCharacters(row[i]).length)));
|
||||
}
|
||||
function padRow(row, widths) {
|
||||
return row.map((v, i) => i ? v.padStart(widths[i], " ") : v.padEnd(widths[i], " "));
|
||||
}
|
||||
function renderTableHead(widths) {
|
||||
return " ".repeat(3) + padRow(tableHead, widths).map(c.bold).join(" ");
|
||||
}
|
||||
function renderBenchmark(result, widths) {
|
||||
const padded = padRow(renderBenchmarkItems(result), widths);
|
||||
return [
|
||||
padded[0],
|
||||
c.blue(padded[1]),
|
||||
c.cyan(padded[2]),
|
||||
c.cyan(padded[3]),
|
||||
c.cyan(padded[4]),
|
||||
c.cyan(padded[5]),
|
||||
c.cyan(padded[6]),
|
||||
c.cyan(padded[7]),
|
||||
c.cyan(padded[8]),
|
||||
c.dim(padded[9]),
|
||||
c.dim(padded[10])
|
||||
].join(" ");
|
||||
}
|
||||
function renderTable(options) {
|
||||
const output = [];
|
||||
const benchMap = {};
|
||||
for (const task of options.tasks) if (task.meta.benchmark && task.result?.benchmark) benchMap[task.id] = {
|
||||
current: task.result.benchmark,
|
||||
baseline: options.compare?.[task.id]
|
||||
};
|
||||
const benchCount = Object.entries(benchMap).length;
|
||||
const columnWidths = computeColumnWidths(Object.values(benchMap).flatMap((v) => [v.current, v.baseline]).filter(notNullish));
|
||||
let idx = 0;
|
||||
const padding = " ".repeat(1 );
|
||||
for (const task of options.tasks) {
|
||||
const duration = task.result?.duration;
|
||||
const bench = benchMap[task.id];
|
||||
let prefix = "";
|
||||
if (idx === 0 && task.meta?.benchmark) prefix += `${renderTableHead(columnWidths)}\n${padding}`;
|
||||
prefix += ` ${getStateSymbol(task)} `;
|
||||
let suffix = "";
|
||||
if (task.type === "suite") suffix += c.dim(` (${getTests(task).length})`);
|
||||
if (task.mode === "skip" || task.mode === "todo") suffix += c.dim(c.gray(" [skipped]"));
|
||||
if (duration != null) {
|
||||
const color = duration > options.slowTestThreshold ? c.yellow : c.green;
|
||||
suffix += color(` ${Math.round(duration)}${c.dim("ms")}`);
|
||||
}
|
||||
if (options.showHeap && task.result?.heap != null) suffix += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
|
||||
if (bench) {
|
||||
let body = renderBenchmark(bench.current, columnWidths);
|
||||
if (options.compare && bench.baseline) {
|
||||
if (bench.current.hz) {
|
||||
const diff = bench.current.hz / bench.baseline.hz;
|
||||
const diffFixed = diff.toFixed(2);
|
||||
if (diffFixed === "1.0.0") body += c.gray(` [${diffFixed}x]`);
|
||||
if (diff > 1) body += c.blue(` [${diffFixed}x] ⇑`);
|
||||
else body += c.red(` [${diffFixed}x] ⇓`);
|
||||
}
|
||||
output.push(padding + prefix + body + suffix);
|
||||
const bodyBaseline = renderBenchmark(bench.baseline, columnWidths);
|
||||
output.push(`${padding} ${bodyBaseline} ${c.dim("(baseline)")}`);
|
||||
} else {
|
||||
if (bench.current.rank === 1 && benchCount > 1) body += c.bold(c.green(" fastest"));
|
||||
if (bench.current.rank === benchCount && benchCount > 2) body += c.bold(c.gray(" slowest"));
|
||||
output.push(padding + prefix + body + suffix);
|
||||
}
|
||||
} else output.push(padding + prefix + task.name + suffix);
|
||||
if (task.result?.state !== "pass" && outputMap.get(task) != null) {
|
||||
let data = outputMap.get(task);
|
||||
if (typeof data === "string") {
|
||||
data = stripVTControlCharacters(data.trim().split("\n").filter(Boolean).pop());
|
||||
if (data === "") data = void 0;
|
||||
}
|
||||
if (data != null) {
|
||||
const out = ` ${" ".repeat(options.level)}${F_RIGHT} ${data}`;
|
||||
output.push(c.gray(truncateString(out, options.columns)));
|
||||
}
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
return output.filter(Boolean).join("\n");
|
||||
}
|
||||
|
||||
class BenchmarkReporter extends DefaultReporter {
|
||||
compare;
|
||||
async onInit(ctx) {
|
||||
super.onInit(ctx);
|
||||
if (this.ctx.config.benchmark?.compare) {
|
||||
const compareFile = pathe.resolve(this.ctx.config.root, this.ctx.config.benchmark?.compare);
|
||||
try {
|
||||
this.compare = flattenFormattedBenchmarkReport(JSON.parse(await fs.promises.readFile(compareFile, "utf-8")));
|
||||
} catch (e) {
|
||||
this.error(`Failed to read '${compareFile}'`, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
onTaskUpdate(packs) {
|
||||
for (const pack of packs) {
|
||||
const task = this.ctx.state.idMap.get(pack[0]);
|
||||
if (task?.type === "suite" && task.result?.state !== "run") task.tasks.filter((task) => task.result?.benchmark).sort((benchA, benchB) => benchA.result.benchmark.mean - benchB.result.benchmark.mean).forEach((bench, idx) => {
|
||||
bench.result.benchmark.rank = Number(idx) + 1;
|
||||
});
|
||||
}
|
||||
}
|
||||
onTestSuiteResult(testSuite) {
|
||||
super.onTestSuiteResult(testSuite);
|
||||
this.printSuiteTable(testSuite);
|
||||
}
|
||||
printTestModule(testModule) {
|
||||
this.printSuiteTable(testModule);
|
||||
}
|
||||
printSuiteTable(testTask) {
|
||||
const state = testTask.state();
|
||||
if (state === "pending" || state === "queued") return;
|
||||
const benches = testTask.task.tasks.filter((t) => t.meta.benchmark);
|
||||
const duration = testTask.task.result?.duration || 0;
|
||||
if (benches.length > 0 && benches.every((t) => t.result?.state !== "run" && t.result?.state !== "queued")) {
|
||||
let title = `\n ${getStateSymbol(testTask.task)} ${formatProjectName(testTask.project)}${getFullName(testTask.task, c.dim(" > "))}`;
|
||||
if (duration != null && duration > this.ctx.config.slowTestThreshold) title += c.yellow(` ${Math.round(duration)}${c.dim("ms")}`);
|
||||
this.log(title);
|
||||
this.log(renderTable({
|
||||
tasks: benches,
|
||||
level: 1,
|
||||
columns: this.ctx.logger.getColumns(),
|
||||
compare: this.compare,
|
||||
showHeap: this.ctx.config.logHeapUsage,
|
||||
slowTestThreshold: this.ctx.config.slowTestThreshold
|
||||
}));
|
||||
}
|
||||
}
|
||||
async onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
||||
super.onFinished(files, errors);
|
||||
// write output for future comparison
|
||||
let outputFile = this.ctx.config.benchmark?.outputJson;
|
||||
if (outputFile) {
|
||||
outputFile = pathe.resolve(this.ctx.config.root, outputFile);
|
||||
const outputDirectory = pathe.dirname(outputFile);
|
||||
if (!fs.existsSync(outputDirectory)) await fs.promises.mkdir(outputDirectory, { recursive: true });
|
||||
const output = createBenchmarkJsonReport(files);
|
||||
await fs.promises.writeFile(outputFile, JSON.stringify(output, null, 2));
|
||||
this.log(`Benchmark report written to ${outputFile}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VerboseBenchmarkReporter extends BenchmarkReporter {
|
||||
verbose = true;
|
||||
}
|
||||
|
||||
const BenchmarkReportsMap = {
|
||||
default: BenchmarkReporter,
|
||||
verbose: VerboseBenchmarkReporter
|
||||
};
|
||||
|
||||
export { BenchmarkReporter as B, VerboseBenchmarkReporter as V, BenchmarkReportsMap as a };
|
||||
37
node_modules/vitest/dist/chunks/index.CdQS2e2Q.js
generated
vendored
Normal file
37
node_modules/vitest/dist/chunks/index.CdQS2e2Q.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import { c as createExpect, a as globalExpect, i as inject, v as vi, b as vitest } from './vi.bdSIJ99Y.js';
|
||||
import { b as bench } from './benchmark.CYdenmiT.js';
|
||||
import { expectTypeOf } from 'expect-type';
|
||||
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
||||
import * as chai from 'chai';
|
||||
import { assert, should } from 'chai';
|
||||
|
||||
const assertType = function assertType() {};
|
||||
|
||||
// TODO: deprecate <reference types="vitest" /> in favor of `<reference types="vitest/config" />`
|
||||
|
||||
var VitestIndex = /*#__PURE__*/Object.freeze({
|
||||
__proto__: null,
|
||||
afterAll: afterAll,
|
||||
afterEach: afterEach,
|
||||
assert: assert,
|
||||
assertType: assertType,
|
||||
beforeAll: beforeAll,
|
||||
beforeEach: beforeEach,
|
||||
bench: bench,
|
||||
chai: chai,
|
||||
createExpect: createExpect,
|
||||
describe: describe,
|
||||
expect: globalExpect,
|
||||
expectTypeOf: expectTypeOf,
|
||||
inject: inject,
|
||||
it: it,
|
||||
onTestFailed: onTestFailed,
|
||||
onTestFinished: onTestFinished,
|
||||
should: should,
|
||||
suite: suite,
|
||||
test: test,
|
||||
vi: vi,
|
||||
vitest: vitest
|
||||
});
|
||||
|
||||
export { VitestIndex as V, assertType as a };
|
||||
587
node_modules/vitest/dist/chunks/index.CmSc2RE5.js
generated
vendored
Normal file
587
node_modules/vitest/dist/chunks/index.CmSc2RE5.js
generated
vendored
Normal file
@@ -0,0 +1,587 @@
|
||||
import { Console } from 'node:console';
|
||||
|
||||
// SEE https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/interfaces.js
|
||||
const LIVING_KEYS = [
|
||||
"DOMException",
|
||||
"URL",
|
||||
"URLSearchParams",
|
||||
"EventTarget",
|
||||
"NamedNodeMap",
|
||||
"Node",
|
||||
"Attr",
|
||||
"Element",
|
||||
"DocumentFragment",
|
||||
"DOMImplementation",
|
||||
"Document",
|
||||
"XMLDocument",
|
||||
"CharacterData",
|
||||
"Text",
|
||||
"CDATASection",
|
||||
"ProcessingInstruction",
|
||||
"Comment",
|
||||
"DocumentType",
|
||||
"NodeList",
|
||||
"RadioNodeList",
|
||||
"HTMLCollection",
|
||||
"HTMLOptionsCollection",
|
||||
"DOMStringMap",
|
||||
"DOMTokenList",
|
||||
"StyleSheetList",
|
||||
"HTMLElement",
|
||||
"HTMLHeadElement",
|
||||
"HTMLTitleElement",
|
||||
"HTMLBaseElement",
|
||||
"HTMLLinkElement",
|
||||
"HTMLMetaElement",
|
||||
"HTMLStyleElement",
|
||||
"HTMLBodyElement",
|
||||
"HTMLHeadingElement",
|
||||
"HTMLParagraphElement",
|
||||
"HTMLHRElement",
|
||||
"HTMLPreElement",
|
||||
"HTMLUListElement",
|
||||
"HTMLOListElement",
|
||||
"HTMLLIElement",
|
||||
"HTMLMenuElement",
|
||||
"HTMLDListElement",
|
||||
"HTMLDivElement",
|
||||
"HTMLAnchorElement",
|
||||
"HTMLAreaElement",
|
||||
"HTMLBRElement",
|
||||
"HTMLButtonElement",
|
||||
"HTMLCanvasElement",
|
||||
"HTMLDataElement",
|
||||
"HTMLDataListElement",
|
||||
"HTMLDetailsElement",
|
||||
"HTMLDialogElement",
|
||||
"HTMLDirectoryElement",
|
||||
"HTMLFieldSetElement",
|
||||
"HTMLFontElement",
|
||||
"HTMLFormElement",
|
||||
"HTMLHtmlElement",
|
||||
"HTMLImageElement",
|
||||
"HTMLInputElement",
|
||||
"HTMLLabelElement",
|
||||
"HTMLLegendElement",
|
||||
"HTMLMapElement",
|
||||
"HTMLMarqueeElement",
|
||||
"HTMLMediaElement",
|
||||
"HTMLMeterElement",
|
||||
"HTMLModElement",
|
||||
"HTMLOptGroupElement",
|
||||
"HTMLOptionElement",
|
||||
"HTMLOutputElement",
|
||||
"HTMLPictureElement",
|
||||
"HTMLProgressElement",
|
||||
"HTMLQuoteElement",
|
||||
"HTMLScriptElement",
|
||||
"HTMLSelectElement",
|
||||
"HTMLSlotElement",
|
||||
"HTMLSourceElement",
|
||||
"HTMLSpanElement",
|
||||
"HTMLTableCaptionElement",
|
||||
"HTMLTableCellElement",
|
||||
"HTMLTableColElement",
|
||||
"HTMLTableElement",
|
||||
"HTMLTimeElement",
|
||||
"HTMLTableRowElement",
|
||||
"HTMLTableSectionElement",
|
||||
"HTMLTemplateElement",
|
||||
"HTMLTextAreaElement",
|
||||
"HTMLUnknownElement",
|
||||
"HTMLFrameElement",
|
||||
"HTMLFrameSetElement",
|
||||
"HTMLIFrameElement",
|
||||
"HTMLEmbedElement",
|
||||
"HTMLObjectElement",
|
||||
"HTMLParamElement",
|
||||
"HTMLVideoElement",
|
||||
"HTMLAudioElement",
|
||||
"HTMLTrackElement",
|
||||
"HTMLFormControlsCollection",
|
||||
"SVGElement",
|
||||
"SVGGraphicsElement",
|
||||
"SVGSVGElement",
|
||||
"SVGTitleElement",
|
||||
"SVGAnimatedString",
|
||||
"SVGNumber",
|
||||
"SVGStringList",
|
||||
"Event",
|
||||
"CloseEvent",
|
||||
"CustomEvent",
|
||||
"MessageEvent",
|
||||
"ErrorEvent",
|
||||
"HashChangeEvent",
|
||||
"PopStateEvent",
|
||||
"StorageEvent",
|
||||
"ProgressEvent",
|
||||
"PageTransitionEvent",
|
||||
"SubmitEvent",
|
||||
"UIEvent",
|
||||
"FocusEvent",
|
||||
"InputEvent",
|
||||
"MouseEvent",
|
||||
"KeyboardEvent",
|
||||
"TouchEvent",
|
||||
"CompositionEvent",
|
||||
"WheelEvent",
|
||||
"BarProp",
|
||||
"External",
|
||||
"Location",
|
||||
"History",
|
||||
"Screen",
|
||||
"Crypto",
|
||||
"Performance",
|
||||
"Navigator",
|
||||
"PluginArray",
|
||||
"MimeTypeArray",
|
||||
"Plugin",
|
||||
"MimeType",
|
||||
"FileReader",
|
||||
"Blob",
|
||||
"File",
|
||||
"FileList",
|
||||
"ValidityState",
|
||||
"DOMParser",
|
||||
"XMLSerializer",
|
||||
"FormData",
|
||||
"XMLHttpRequestEventTarget",
|
||||
"XMLHttpRequestUpload",
|
||||
"XMLHttpRequest",
|
||||
"WebSocket",
|
||||
"NodeFilter",
|
||||
"NodeIterator",
|
||||
"TreeWalker",
|
||||
"AbstractRange",
|
||||
"Range",
|
||||
"StaticRange",
|
||||
"Selection",
|
||||
"Storage",
|
||||
"CustomElementRegistry",
|
||||
"ShadowRoot",
|
||||
"MutationObserver",
|
||||
"MutationRecord",
|
||||
"Headers",
|
||||
"AbortController",
|
||||
"AbortSignal",
|
||||
"Uint8Array",
|
||||
"Uint16Array",
|
||||
"Uint32Array",
|
||||
"Uint8ClampedArray",
|
||||
"Int8Array",
|
||||
"Int16Array",
|
||||
"Int32Array",
|
||||
"Float32Array",
|
||||
"Float64Array",
|
||||
"ArrayBuffer",
|
||||
"DOMRectReadOnly",
|
||||
"DOMRect",
|
||||
"Image",
|
||||
"Audio",
|
||||
"Option",
|
||||
"CSS"
|
||||
];
|
||||
const OTHER_KEYS = [
|
||||
"addEventListener",
|
||||
"alert",
|
||||
"blur",
|
||||
"cancelAnimationFrame",
|
||||
"close",
|
||||
"confirm",
|
||||
"createPopup",
|
||||
"dispatchEvent",
|
||||
"document",
|
||||
"focus",
|
||||
"frames",
|
||||
"getComputedStyle",
|
||||
"history",
|
||||
"innerHeight",
|
||||
"innerWidth",
|
||||
"length",
|
||||
"location",
|
||||
"matchMedia",
|
||||
"moveBy",
|
||||
"moveTo",
|
||||
"name",
|
||||
"navigator",
|
||||
"open",
|
||||
"outerHeight",
|
||||
"outerWidth",
|
||||
"pageXOffset",
|
||||
"pageYOffset",
|
||||
"parent",
|
||||
"postMessage",
|
||||
"print",
|
||||
"prompt",
|
||||
"removeEventListener",
|
||||
"requestAnimationFrame",
|
||||
"resizeBy",
|
||||
"resizeTo",
|
||||
"screen",
|
||||
"screenLeft",
|
||||
"screenTop",
|
||||
"screenX",
|
||||
"screenY",
|
||||
"scroll",
|
||||
"scrollBy",
|
||||
"scrollLeft",
|
||||
"scrollTo",
|
||||
"scrollTop",
|
||||
"scrollX",
|
||||
"scrollY",
|
||||
"self",
|
||||
"stop",
|
||||
"top",
|
||||
"Window",
|
||||
"window"
|
||||
];
|
||||
const KEYS = LIVING_KEYS.concat(OTHER_KEYS);
|
||||
|
||||
const skipKeys = [
|
||||
"window",
|
||||
"self",
|
||||
"top",
|
||||
"parent"
|
||||
];
|
||||
function getWindowKeys(global, win, additionalKeys = []) {
|
||||
const keysArray = [...additionalKeys, ...KEYS];
|
||||
const keys = new Set(keysArray.concat(Object.getOwnPropertyNames(win)).filter((k) => {
|
||||
if (skipKeys.includes(k)) return false;
|
||||
if (k in global) return keysArray.includes(k);
|
||||
return true;
|
||||
}));
|
||||
return keys;
|
||||
}
|
||||
function isClassLikeName(name) {
|
||||
return name[0] === name[0].toUpperCase();
|
||||
}
|
||||
function populateGlobal(global, win, options = {}) {
|
||||
const { bindFunctions = false } = options;
|
||||
const keys = getWindowKeys(global, win, options.additionalKeys);
|
||||
const originals = /* @__PURE__ */ new Map();
|
||||
const overrideObject = /* @__PURE__ */ new Map();
|
||||
for (const key of keys) {
|
||||
const boundFunction = bindFunctions && typeof win[key] === "function" && !isClassLikeName(key) && win[key].bind(win);
|
||||
if (KEYS.includes(key) && key in global) originals.set(key, global[key]);
|
||||
Object.defineProperty(global, key, {
|
||||
get() {
|
||||
if (overrideObject.has(key)) return overrideObject.get(key);
|
||||
if (boundFunction) return boundFunction;
|
||||
return win[key];
|
||||
},
|
||||
set(v) {
|
||||
overrideObject.set(key, v);
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
global.window = global;
|
||||
global.self = global;
|
||||
global.top = global;
|
||||
global.parent = global;
|
||||
if (global.global) global.global = global;
|
||||
// rewrite defaultView to reference the same global context
|
||||
if (global.document && global.document.defaultView) Object.defineProperty(global.document, "defaultView", {
|
||||
get: () => global,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
skipKeys.forEach((k) => keys.add(k));
|
||||
return {
|
||||
keys,
|
||||
skipKeys,
|
||||
originals
|
||||
};
|
||||
}
|
||||
|
||||
var edge = {
|
||||
name: "edge-runtime",
|
||||
transformMode: "ssr",
|
||||
async setupVM() {
|
||||
const { EdgeVM } = await import('@edge-runtime/vm');
|
||||
const vm = new EdgeVM({ extend: (context) => {
|
||||
context.global = context;
|
||||
context.Buffer = Buffer;
|
||||
return context;
|
||||
} });
|
||||
return {
|
||||
getVmContext() {
|
||||
return vm.context;
|
||||
},
|
||||
teardown() {
|
||||
// nothing to teardown
|
||||
}
|
||||
};
|
||||
},
|
||||
async setup(global) {
|
||||
const { EdgeVM } = await import('@edge-runtime/vm');
|
||||
const vm = new EdgeVM({ extend: (context) => {
|
||||
context.global = context;
|
||||
context.Buffer = Buffer;
|
||||
KEYS.forEach((key) => {
|
||||
if (key in global) context[key] = global[key];
|
||||
});
|
||||
return context;
|
||||
} });
|
||||
const { keys, originals } = populateGlobal(global, vm.context, { bindFunctions: true });
|
||||
return { teardown(global) {
|
||||
keys.forEach((key) => delete global[key]);
|
||||
originals.forEach((v, k) => global[k] = v);
|
||||
} };
|
||||
}
|
||||
};
|
||||
|
||||
async function teardownWindow(win) {
|
||||
if (win.close && win.happyDOM.abort) {
|
||||
await win.happyDOM.abort();
|
||||
win.close();
|
||||
} else win.happyDOM.cancelAsync();
|
||||
}
|
||||
var happy = {
|
||||
name: "happy-dom",
|
||||
transformMode: "web",
|
||||
async setupVM({ happyDOM = {} }) {
|
||||
const { Window } = await import('happy-dom');
|
||||
let win = new Window({
|
||||
...happyDOM,
|
||||
console: console && globalThis.console ? globalThis.console : void 0,
|
||||
url: happyDOM.url || "http://localhost:3000",
|
||||
settings: {
|
||||
...happyDOM.settings,
|
||||
disableErrorCapturing: true
|
||||
}
|
||||
});
|
||||
// TODO: browser doesn't expose Buffer, but a lot of dependencies use it
|
||||
win.Buffer = Buffer;
|
||||
// inject structuredClone if it exists
|
||||
if (typeof structuredClone !== "undefined" && !win.structuredClone) win.structuredClone = structuredClone;
|
||||
return {
|
||||
getVmContext() {
|
||||
return win;
|
||||
},
|
||||
async teardown() {
|
||||
await teardownWindow(win);
|
||||
win = void 0;
|
||||
}
|
||||
};
|
||||
},
|
||||
async setup(global, { happyDOM = {} }) {
|
||||
// happy-dom v3 introduced a breaking change to Window, but
|
||||
// provides GlobalWindow as a way to use previous behaviour
|
||||
const { Window, GlobalWindow } = await import('happy-dom');
|
||||
const win = new (GlobalWindow || Window)({
|
||||
...happyDOM,
|
||||
console: console && global.console ? global.console : void 0,
|
||||
url: happyDOM.url || "http://localhost:3000",
|
||||
settings: {
|
||||
...happyDOM.settings,
|
||||
disableErrorCapturing: true
|
||||
}
|
||||
});
|
||||
const { keys, originals } = populateGlobal(global, win, {
|
||||
bindFunctions: true,
|
||||
additionalKeys: [
|
||||
"Request",
|
||||
"Response",
|
||||
"MessagePort",
|
||||
"fetch"
|
||||
]
|
||||
});
|
||||
return { async teardown(global) {
|
||||
await teardownWindow(win);
|
||||
keys.forEach((key) => delete global[key]);
|
||||
originals.forEach((v, k) => global[k] = v);
|
||||
} };
|
||||
}
|
||||
};
|
||||
|
||||
function catchWindowErrors(window) {
|
||||
let userErrorListenerCount = 0;
|
||||
function throwUnhandlerError(e) {
|
||||
if (userErrorListenerCount === 0 && e.error != null) process.emit("uncaughtException", e.error);
|
||||
}
|
||||
const addEventListener = window.addEventListener.bind(window);
|
||||
const removeEventListener = window.removeEventListener.bind(window);
|
||||
window.addEventListener("error", throwUnhandlerError);
|
||||
window.addEventListener = function(...args) {
|
||||
if (args[0] === "error") userErrorListenerCount++;
|
||||
return addEventListener.apply(this, args);
|
||||
};
|
||||
window.removeEventListener = function(...args) {
|
||||
if (args[0] === "error" && userErrorListenerCount) userErrorListenerCount--;
|
||||
return removeEventListener.apply(this, args);
|
||||
};
|
||||
return function clearErrorHandlers() {
|
||||
window.removeEventListener("error", throwUnhandlerError);
|
||||
};
|
||||
}
|
||||
var jsdom = {
|
||||
name: "jsdom",
|
||||
transformMode: "web",
|
||||
async setupVM({ jsdom = {} }) {
|
||||
const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = await import('jsdom');
|
||||
const { html = "<!DOCTYPE html>", userAgent, url = "http://localhost:3000", contentType = "text/html", pretendToBeVisual = true, includeNodeLocations = false, runScripts = "dangerously", resources, console = false, cookieJar = false,...restOptions } = jsdom;
|
||||
let dom = new JSDOM(html, {
|
||||
pretendToBeVisual,
|
||||
resources: resources ?? (userAgent ? new ResourceLoader({ userAgent }) : void 0),
|
||||
runScripts,
|
||||
url,
|
||||
virtualConsole: console && globalThis.console ? new VirtualConsole().sendTo(globalThis.console) : void 0,
|
||||
cookieJar: cookieJar ? new CookieJar() : void 0,
|
||||
includeNodeLocations,
|
||||
contentType,
|
||||
userAgent,
|
||||
...restOptions
|
||||
});
|
||||
const clearWindowErrors = catchWindowErrors(dom.window);
|
||||
// TODO: browser doesn't expose Buffer, but a lot of dependencies use it
|
||||
dom.window.Buffer = Buffer;
|
||||
dom.window.jsdom = dom;
|
||||
// inject web globals if they missing in JSDOM but otherwise available in Nodejs
|
||||
// https://nodejs.org/dist/latest/docs/api/globals.html
|
||||
const globalNames = [
|
||||
"structuredClone",
|
||||
"fetch",
|
||||
"Request",
|
||||
"Response",
|
||||
"BroadcastChannel",
|
||||
"MessageChannel",
|
||||
"MessagePort",
|
||||
"TextEncoder",
|
||||
"TextDecoder"
|
||||
];
|
||||
for (const name of globalNames) {
|
||||
const value = globalThis[name];
|
||||
if (typeof value !== "undefined" && typeof dom.window[name] === "undefined") dom.window[name] = value;
|
||||
}
|
||||
return {
|
||||
getVmContext() {
|
||||
return dom.getInternalVMContext();
|
||||
},
|
||||
teardown() {
|
||||
clearWindowErrors();
|
||||
dom.window.close();
|
||||
dom = void 0;
|
||||
}
|
||||
};
|
||||
},
|
||||
async setup(global, { jsdom = {} }) {
|
||||
const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = await import('jsdom');
|
||||
const { html = "<!DOCTYPE html>", userAgent, url = "http://localhost:3000", contentType = "text/html", pretendToBeVisual = true, includeNodeLocations = false, runScripts = "dangerously", resources, console = false, cookieJar = false,...restOptions } = jsdom;
|
||||
const dom = new JSDOM(html, {
|
||||
pretendToBeVisual,
|
||||
resources: resources ?? (userAgent ? new ResourceLoader({ userAgent }) : void 0),
|
||||
runScripts,
|
||||
url,
|
||||
virtualConsole: console && global.console ? new VirtualConsole().sendTo(global.console) : void 0,
|
||||
cookieJar: cookieJar ? new CookieJar() : void 0,
|
||||
includeNodeLocations,
|
||||
contentType,
|
||||
userAgent,
|
||||
...restOptions
|
||||
});
|
||||
const { keys, originals } = populateGlobal(global, dom.window, { bindFunctions: true });
|
||||
const clearWindowErrors = catchWindowErrors(global);
|
||||
global.jsdom = dom;
|
||||
return { teardown(global) {
|
||||
clearWindowErrors();
|
||||
dom.window.close();
|
||||
delete global.jsdom;
|
||||
keys.forEach((key) => delete global[key]);
|
||||
originals.forEach((v, k) => global[k] = v);
|
||||
} };
|
||||
}
|
||||
};
|
||||
|
||||
// some globals we do not want, either because deprecated or we set it ourselves
|
||||
const denyList = new Set([
|
||||
"GLOBAL",
|
||||
"root",
|
||||
"global",
|
||||
"Buffer",
|
||||
"ArrayBuffer",
|
||||
"Uint8Array"
|
||||
]);
|
||||
const nodeGlobals = new Map(Object.getOwnPropertyNames(globalThis).filter((global) => !denyList.has(global)).map((nodeGlobalsKey) => {
|
||||
const descriptor = Object.getOwnPropertyDescriptor(globalThis, nodeGlobalsKey);
|
||||
if (!descriptor) throw new Error(`No property descriptor for ${nodeGlobalsKey}, this is a bug in Vitest.`);
|
||||
return [nodeGlobalsKey, descriptor];
|
||||
}));
|
||||
var node = {
|
||||
name: "node",
|
||||
transformMode: "ssr",
|
||||
async setupVM() {
|
||||
const vm = await import('node:vm');
|
||||
let context = vm.createContext();
|
||||
let global = vm.runInContext("this", context);
|
||||
const contextGlobals = new Set(Object.getOwnPropertyNames(global));
|
||||
for (const [nodeGlobalsKey, descriptor] of nodeGlobals) if (!contextGlobals.has(nodeGlobalsKey)) if (descriptor.configurable) Object.defineProperty(global, nodeGlobalsKey, {
|
||||
configurable: true,
|
||||
enumerable: descriptor.enumerable,
|
||||
get() {
|
||||
// @ts-expect-error: no index signature
|
||||
const val = globalThis[nodeGlobalsKey];
|
||||
// override lazy getter
|
||||
Object.defineProperty(global, nodeGlobalsKey, {
|
||||
configurable: true,
|
||||
enumerable: descriptor.enumerable,
|
||||
value: val,
|
||||
writable: descriptor.writable === true || nodeGlobalsKey === "performance"
|
||||
});
|
||||
return val;
|
||||
},
|
||||
set(val) {
|
||||
// override lazy getter
|
||||
Object.defineProperty(global, nodeGlobalsKey, {
|
||||
configurable: true,
|
||||
enumerable: descriptor.enumerable,
|
||||
value: val,
|
||||
writable: true
|
||||
});
|
||||
}
|
||||
});
|
||||
else if ("value" in descriptor) Object.defineProperty(global, nodeGlobalsKey, {
|
||||
configurable: false,
|
||||
enumerable: descriptor.enumerable,
|
||||
value: descriptor.value,
|
||||
writable: descriptor.writable
|
||||
});
|
||||
else Object.defineProperty(global, nodeGlobalsKey, {
|
||||
configurable: false,
|
||||
enumerable: descriptor.enumerable,
|
||||
get: descriptor.get,
|
||||
set: descriptor.set
|
||||
});
|
||||
global.global = global;
|
||||
global.Buffer = Buffer;
|
||||
global.ArrayBuffer = ArrayBuffer;
|
||||
// TextEncoder (global or via 'util') references a Uint8Array constructor
|
||||
// different than the global one used by users in tests. This makes sure the
|
||||
// same constructor is referenced by both.
|
||||
global.Uint8Array = Uint8Array;
|
||||
return {
|
||||
getVmContext() {
|
||||
return context;
|
||||
},
|
||||
teardown() {
|
||||
context = void 0;
|
||||
global = void 0;
|
||||
}
|
||||
};
|
||||
},
|
||||
async setup(global) {
|
||||
global.console.Console = Console;
|
||||
return { teardown(global) {
|
||||
delete global.console.Console;
|
||||
} };
|
||||
}
|
||||
};
|
||||
|
||||
const environments = {
|
||||
node,
|
||||
jsdom,
|
||||
"happy-dom": happy,
|
||||
"edge-runtime": edge
|
||||
};
|
||||
|
||||
export { environments as e, populateGlobal as p };
|
||||
105
node_modules/vitest/dist/chunks/index.CwejwG0H.js
generated
vendored
Normal file
105
node_modules/vitest/dist/chunks/index.CwejwG0H.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
import * as chai from 'chai';
|
||||
import { resolve } from 'node:path';
|
||||
import { l as loadDiffConfig, b as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.Dd054P77.js';
|
||||
import { distDir } from '../path.js';
|
||||
import { r as rpc } from './rpc.-pEldfrD.js';
|
||||
import { g as getWorkerState } from './utils.XdZDrNZV.js';
|
||||
|
||||
function setupChaiConfig(config) {
|
||||
Object.assign(chai.config, config);
|
||||
}
|
||||
|
||||
async function resolveSnapshotEnvironment(config, executor) {
|
||||
if (!config.snapshotEnvironment) {
|
||||
const { VitestNodeSnapshotEnvironment } = await import('./node.fjCdwEIl.js');
|
||||
return new VitestNodeSnapshotEnvironment();
|
||||
}
|
||||
const mod = await executor.executeId(config.snapshotEnvironment);
|
||||
if (typeof mod.default !== "object" || !mod.default) throw new Error("Snapshot environment module must have a default export object with a shape of `SnapshotEnvironment`");
|
||||
return mod.default;
|
||||
}
|
||||
|
||||
const runnersFile = resolve(distDir, "runners.js");
|
||||
async function getTestRunnerConstructor(config, executor) {
|
||||
if (!config.runner) {
|
||||
const { VitestTestRunner, NodeBenchmarkRunner } = await executor.executeFile(runnersFile);
|
||||
return config.mode === "test" ? VitestTestRunner : NodeBenchmarkRunner;
|
||||
}
|
||||
const mod = await executor.executeId(config.runner);
|
||||
if (!mod.default && typeof mod.default !== "function") throw new Error(`Runner must export a default function, but got ${typeof mod.default} imported from ${config.runner}`);
|
||||
return mod.default;
|
||||
}
|
||||
async function resolveTestRunner(config, executor) {
|
||||
const TestRunner = await getTestRunnerConstructor(config, executor);
|
||||
const testRunner = new TestRunner(config);
|
||||
// inject private executor to every runner
|
||||
Object.defineProperty(testRunner, "__vitest_executor", {
|
||||
value: executor,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
if (!testRunner.config) testRunner.config = config;
|
||||
if (!testRunner.importFile) throw new Error("Runner must implement \"importFile\" method.");
|
||||
const [diffOptions] = await Promise.all([loadDiffConfig(config, executor), loadSnapshotSerializers(config, executor)]);
|
||||
testRunner.config.diffOptions = diffOptions;
|
||||
// patch some methods, so custom runners don't need to call RPC
|
||||
const originalOnTaskUpdate = testRunner.onTaskUpdate;
|
||||
testRunner.onTaskUpdate = async (task, events) => {
|
||||
const p = rpc().onTaskUpdate(task, events);
|
||||
await originalOnTaskUpdate?.call(testRunner, task, events);
|
||||
return p;
|
||||
};
|
||||
// patch some methods, so custom runners don't need to call RPC
|
||||
const originalOnTestAnnotate = testRunner.onTestAnnotate;
|
||||
testRunner.onTestAnnotate = async (test, annotation) => {
|
||||
const p = rpc().onTaskAnnotate(test.id, annotation);
|
||||
const overridenResult = await originalOnTestAnnotate?.call(testRunner, test, annotation);
|
||||
const vitestResult = await p;
|
||||
return overridenResult || vitestResult;
|
||||
};
|
||||
const originalOnCollectStart = testRunner.onCollectStart;
|
||||
testRunner.onCollectStart = async (file) => {
|
||||
await rpc().onQueued(file);
|
||||
await originalOnCollectStart?.call(testRunner, file);
|
||||
};
|
||||
const originalOnCollected = testRunner.onCollected;
|
||||
testRunner.onCollected = async (files) => {
|
||||
const state = getWorkerState();
|
||||
files.forEach((file) => {
|
||||
file.prepareDuration = state.durations.prepare;
|
||||
file.environmentLoad = state.durations.environment;
|
||||
// should be collected only for a single test file in a batch
|
||||
state.durations.prepare = 0;
|
||||
state.durations.environment = 0;
|
||||
});
|
||||
rpc().onCollected(files);
|
||||
await originalOnCollected?.call(testRunner, files);
|
||||
};
|
||||
const originalOnAfterRun = testRunner.onAfterRunFiles;
|
||||
testRunner.onAfterRunFiles = async (files) => {
|
||||
const state = getWorkerState();
|
||||
const coverage = await takeCoverageInsideWorker(config.coverage, executor);
|
||||
if (coverage) rpc().onAfterSuiteRun({
|
||||
coverage,
|
||||
testFiles: files.map((file) => file.name).sort(),
|
||||
transformMode: state.environment.transformMode,
|
||||
projectName: state.ctx.projectName
|
||||
});
|
||||
await originalOnAfterRun?.call(testRunner, files);
|
||||
};
|
||||
const originalOnAfterRunTask = testRunner.onAfterRunTask;
|
||||
testRunner.onAfterRunTask = async (test) => {
|
||||
if (config.bail && test.result?.state === "fail") {
|
||||
const previousFailures = await rpc().getCountOfFailedTests();
|
||||
const currentFailures = 1 + previousFailures;
|
||||
if (currentFailures >= config.bail) {
|
||||
rpc().onCancel("test-failure");
|
||||
testRunner.cancel?.("test-failure");
|
||||
}
|
||||
}
|
||||
await originalOnAfterRunTask?.call(testRunner, test);
|
||||
};
|
||||
return testRunner;
|
||||
}
|
||||
|
||||
export { resolveSnapshotEnvironment as a, resolveTestRunner as r, setupChaiConfig as s };
|
||||
213
node_modules/vitest/dist/chunks/index.D3XRDfWc.js
generated
vendored
Normal file
213
node_modules/vitest/dist/chunks/index.D3XRDfWc.js
generated
vendored
Normal file
@@ -0,0 +1,213 @@
|
||||
import process from 'node:process';
|
||||
import fs from 'node:fs/promises';
|
||||
import path, { resolve } from 'node:path';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { x } from 'tinyexec';
|
||||
|
||||
const AGENTS = [
|
||||
"npm",
|
||||
"yarn",
|
||||
"yarn@berry",
|
||||
"pnpm",
|
||||
"pnpm@6",
|
||||
"bun",
|
||||
"deno"
|
||||
];
|
||||
const LOCKS = {
|
||||
"bun.lock": "bun",
|
||||
"bun.lockb": "bun",
|
||||
"deno.lock": "deno",
|
||||
"pnpm-lock.yaml": "pnpm",
|
||||
"pnpm-workspace.yaml": "pnpm",
|
||||
"yarn.lock": "yarn",
|
||||
"package-lock.json": "npm",
|
||||
"npm-shrinkwrap.json": "npm"
|
||||
};
|
||||
const INSTALL_METADATA = {
|
||||
"node_modules/.deno/": "deno",
|
||||
"node_modules/.pnpm/": "pnpm",
|
||||
"node_modules/.yarn-state.yml": "yarn",
|
||||
// yarn v2+ (node-modules)
|
||||
"node_modules/.yarn_integrity": "yarn",
|
||||
// yarn v1
|
||||
"node_modules/.package-lock.json": "npm",
|
||||
".pnp.cjs": "yarn",
|
||||
// yarn v3+ (pnp)
|
||||
".pnp.js": "yarn",
|
||||
// yarn v2 (pnp)
|
||||
"bun.lock": "bun",
|
||||
"bun.lockb": "bun"
|
||||
};
|
||||
|
||||
async function pathExists(path2, type) {
|
||||
try {
|
||||
const stat = await fs.stat(path2);
|
||||
return type === "file" ? stat.isFile() : stat.isDirectory();
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function* lookup(cwd = process.cwd()) {
|
||||
let directory = path.resolve(cwd);
|
||||
const { root } = path.parse(directory);
|
||||
while (directory && directory !== root) {
|
||||
yield directory;
|
||||
directory = path.dirname(directory);
|
||||
}
|
||||
}
|
||||
async function parsePackageJson(filepath, onUnknown) {
|
||||
return !filepath || !pathExists(filepath, "file") ? null : await handlePackageManager(filepath, onUnknown);
|
||||
}
|
||||
async function detect(options = {}) {
|
||||
const {
|
||||
cwd,
|
||||
strategies = ["lockfile", "packageManager-field", "devEngines-field"],
|
||||
onUnknown
|
||||
} = options;
|
||||
let stopDir;
|
||||
if (typeof options.stopDir === "string") {
|
||||
const resolved = path.resolve(options.stopDir);
|
||||
stopDir = (dir) => dir === resolved;
|
||||
} else {
|
||||
stopDir = options.stopDir;
|
||||
}
|
||||
for (const directory of lookup(cwd)) {
|
||||
for (const strategy of strategies) {
|
||||
switch (strategy) {
|
||||
case "lockfile": {
|
||||
for (const lock of Object.keys(LOCKS)) {
|
||||
if (await pathExists(path.join(directory, lock), "file")) {
|
||||
const name = LOCKS[lock];
|
||||
const result = await parsePackageJson(path.join(directory, "package.json"), onUnknown);
|
||||
if (result)
|
||||
return result;
|
||||
else
|
||||
return { name, agent: name };
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "packageManager-field":
|
||||
case "devEngines-field": {
|
||||
const result = await parsePackageJson(path.join(directory, "package.json"), onUnknown);
|
||||
if (result)
|
||||
return result;
|
||||
break;
|
||||
}
|
||||
case "install-metadata": {
|
||||
for (const metadata of Object.keys(INSTALL_METADATA)) {
|
||||
const fileOrDir = metadata.endsWith("/") ? "dir" : "file";
|
||||
if (await pathExists(path.join(directory, metadata), fileOrDir)) {
|
||||
const name = INSTALL_METADATA[metadata];
|
||||
const agent = name === "yarn" ? isMetadataYarnClassic(metadata) ? "yarn" : "yarn@berry" : name;
|
||||
return { name, agent };
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stopDir?.(directory))
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function getNameAndVer(pkg) {
|
||||
const handelVer = (version) => version?.match(/\d+(\.\d+){0,2}/)?.[0] ?? version;
|
||||
if (typeof pkg.packageManager === "string") {
|
||||
const [name, ver] = pkg.packageManager.replace(/^\^/, "").split("@");
|
||||
return { name, ver: handelVer(ver) };
|
||||
}
|
||||
if (typeof pkg.devEngines?.packageManager?.name === "string") {
|
||||
return {
|
||||
name: pkg.devEngines.packageManager.name,
|
||||
ver: handelVer(pkg.devEngines.packageManager.version)
|
||||
};
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
async function handlePackageManager(filepath, onUnknown) {
|
||||
try {
|
||||
const pkg = JSON.parse(await fs.readFile(filepath, "utf8"));
|
||||
let agent;
|
||||
const nameAndVer = getNameAndVer(pkg);
|
||||
if (nameAndVer) {
|
||||
const name = nameAndVer.name;
|
||||
const ver = nameAndVer.ver;
|
||||
let version = ver;
|
||||
if (name === "yarn" && ver && Number.parseInt(ver) > 1) {
|
||||
agent = "yarn@berry";
|
||||
version = "berry";
|
||||
return { name, agent, version };
|
||||
} else if (name === "pnpm" && ver && Number.parseInt(ver) < 7) {
|
||||
agent = "pnpm@6";
|
||||
return { name, agent, version };
|
||||
} else if (AGENTS.includes(name)) {
|
||||
agent = name;
|
||||
return { name, agent, version };
|
||||
} else {
|
||||
return onUnknown?.(pkg.packageManager) ?? null;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function isMetadataYarnClassic(metadataPath) {
|
||||
return metadataPath.endsWith(".yarn_integrity");
|
||||
}
|
||||
|
||||
// src/detect.ts
|
||||
async function detectPackageManager(cwd = process.cwd()) {
|
||||
const result = await detect({
|
||||
cwd,
|
||||
onUnknown(packageManager) {
|
||||
console.warn("[@antfu/install-pkg] Unknown packageManager:", packageManager);
|
||||
return void 0;
|
||||
}
|
||||
});
|
||||
return result?.agent || null;
|
||||
}
|
||||
async function installPackage(names, options = {}) {
|
||||
const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
|
||||
const [agent] = detectedAgent.split("@");
|
||||
if (!Array.isArray(names))
|
||||
names = [names];
|
||||
const args = (typeof options.additionalArgs === "function" ? options.additionalArgs(agent, detectedAgent) : options.additionalArgs) || [];
|
||||
if (options.preferOffline) {
|
||||
if (detectedAgent === "yarn@berry")
|
||||
args.unshift("--cached");
|
||||
else
|
||||
args.unshift("--prefer-offline");
|
||||
}
|
||||
if (agent === "pnpm") {
|
||||
args.unshift(
|
||||
/**
|
||||
* Prevent pnpm from removing installed devDeps while `NODE_ENV` is `production`
|
||||
* @see https://pnpm.io/cli/install#--prod--p
|
||||
*/
|
||||
"--prod=false"
|
||||
);
|
||||
if (existsSync(resolve(options.cwd ?? process.cwd(), "pnpm-workspace.yaml"))) {
|
||||
args.unshift("-w");
|
||||
}
|
||||
}
|
||||
return x(
|
||||
agent,
|
||||
[
|
||||
agent === "yarn" ? "add" : "install",
|
||||
options.dev ? "-D" : "",
|
||||
...args,
|
||||
...names
|
||||
].filter(Boolean),
|
||||
{
|
||||
nodeOptions: {
|
||||
stdio: options.silent ? "ignore" : "inherit",
|
||||
cwd: options.cwd
|
||||
},
|
||||
throwOnError: true
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export { detectPackageManager, installPackage };
|
||||
2183
node_modules/vitest/dist/chunks/index.VByaPkjc.js
generated
vendored
Normal file
2183
node_modules/vitest/dist/chunks/index.VByaPkjc.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
6584
node_modules/vitest/dist/chunks/index.X0nbfr6-.js
generated
vendored
Normal file
6584
node_modules/vitest/dist/chunks/index.X0nbfr6-.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
57
node_modules/vitest/dist/chunks/inspector.C914Efll.js
generated
vendored
Normal file
57
node_modules/vitest/dist/chunks/inspector.C914Efll.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
import { createRequire } from 'node:module';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
|
||||
const __require = createRequire(import.meta.url);
|
||||
let inspector;
|
||||
let session;
|
||||
/**
|
||||
* Enables debugging inside `worker_threads` and `child_process`.
|
||||
* Should be called as early as possible when worker/process has been set up.
|
||||
*/
|
||||
function setupInspect(ctx) {
|
||||
const config = ctx.config;
|
||||
const isEnabled = config.inspector.enabled;
|
||||
if (isEnabled) {
|
||||
inspector = __require("node:inspector");
|
||||
// Inspector may be open already if "isolate: false" is used
|
||||
const isOpen = inspector.url() !== void 0;
|
||||
if (!isOpen) {
|
||||
inspector.open(config.inspector.port, config.inspector.host, config.inspector.waitForDebugger);
|
||||
if (config.inspectBrk) {
|
||||
const firstTestFile = typeof ctx.files[0] === "string" ? ctx.files[0] : ctx.files[0].filepath;
|
||||
// Stop at first test file
|
||||
if (firstTestFile) {
|
||||
session = new inspector.Session();
|
||||
session.connect();
|
||||
session.post("Debugger.enable");
|
||||
session.post("Debugger.setBreakpointByUrl", {
|
||||
lineNumber: 0,
|
||||
url: pathToFileURL(firstTestFile)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const keepOpen = shouldKeepOpen(config);
|
||||
return function cleanup() {
|
||||
if (isEnabled && !keepOpen && inspector) {
|
||||
inspector.close();
|
||||
session?.disconnect();
|
||||
}
|
||||
};
|
||||
}
|
||||
function closeInspector(config) {
|
||||
const keepOpen = shouldKeepOpen(config);
|
||||
if (inspector && !keepOpen) {
|
||||
inspector.close();
|
||||
session?.disconnect();
|
||||
}
|
||||
}
|
||||
function shouldKeepOpen(config) {
|
||||
// In watch mode the inspector can persist re-runs if isolation is disabled and a single worker is used
|
||||
const isIsolatedSingleThread = config.pool === "threads" && config.poolOptions?.threads?.isolate === false && config.poolOptions?.threads?.singleThread;
|
||||
const isIsolatedSingleFork = config.pool === "forks" && config.poolOptions?.forks?.isolate === false && config.poolOptions?.forks?.singleFork;
|
||||
return config.watch && (isIsolatedSingleFork || isIsolatedSingleThread);
|
||||
}
|
||||
|
||||
export { closeInspector as c, setupInspect as s };
|
||||
17
node_modules/vitest/dist/chunks/mocker.d.BE_2ls6u.d.ts
generated
vendored
Normal file
17
node_modules/vitest/dist/chunks/mocker.d.BE_2ls6u.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { MockedModuleType } from '@vitest/mocker';
|
||||
|
||||
type Promisable<T> = T | Promise<T>;
|
||||
type MockFactoryWithHelper<M = unknown> = (importOriginal: <T extends M = M>() => Promise<T>) => Promisable<Partial<M>>;
|
||||
type MockFactory = () => any;
|
||||
interface MockOptions {
|
||||
spy?: boolean;
|
||||
}
|
||||
interface PendingSuiteMock {
|
||||
id: string;
|
||||
importer: string;
|
||||
action: "mock" | "unmock";
|
||||
type?: MockedModuleType;
|
||||
factory?: MockFactory;
|
||||
}
|
||||
|
||||
export type { MockFactoryWithHelper as M, PendingSuiteMock as P, MockOptions as a, MockFactory as b };
|
||||
15
node_modules/vitest/dist/chunks/node.fjCdwEIl.js
generated
vendored
Normal file
15
node_modules/vitest/dist/chunks/node.fjCdwEIl.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
|
||||
import { g as getWorkerState } from './utils.XdZDrNZV.js';
|
||||
import '@vitest/utils';
|
||||
|
||||
class VitestNodeSnapshotEnvironment extends NodeSnapshotEnvironment {
|
||||
getHeader() {
|
||||
return `// Vitest Snapshot v${this.getVersion()}, https://vitest.dev/guide/snapshot.html`;
|
||||
}
|
||||
resolvePath(filepath) {
|
||||
const rpc = getWorkerState().rpc;
|
||||
return rpc.resolveSnapshotPath(filepath);
|
||||
}
|
||||
}
|
||||
|
||||
export { VitestNodeSnapshotEnvironment };
|
||||
3168
node_modules/vitest/dist/chunks/reporters.d.BuRON0I0.d.ts
generated
vendored
Normal file
3168
node_modules/vitest/dist/chunks/reporters.d.BuRON0I0.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
83
node_modules/vitest/dist/chunks/rpc.-pEldfrD.js
generated
vendored
Normal file
83
node_modules/vitest/dist/chunks/rpc.-pEldfrD.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
import { getSafeTimers } from '@vitest/utils';
|
||||
import { c as createBirpc } from './index.B521nVV-.js';
|
||||
import { g as getWorkerState } from './utils.XdZDrNZV.js';
|
||||
|
||||
const { get } = Reflect;
|
||||
function withSafeTimers(fn) {
|
||||
const { setTimeout, clearTimeout, nextTick, setImmediate, clearImmediate } = getSafeTimers();
|
||||
const currentSetTimeout = globalThis.setTimeout;
|
||||
const currentClearTimeout = globalThis.clearTimeout;
|
||||
const currentSetImmediate = globalThis.setImmediate;
|
||||
const currentClearImmediate = globalThis.clearImmediate;
|
||||
const currentNextTick = globalThis.process?.nextTick;
|
||||
try {
|
||||
globalThis.setTimeout = setTimeout;
|
||||
globalThis.clearTimeout = clearTimeout;
|
||||
globalThis.setImmediate = setImmediate;
|
||||
globalThis.clearImmediate = clearImmediate;
|
||||
if (globalThis.process) globalThis.process.nextTick = nextTick;
|
||||
const result = fn();
|
||||
return result;
|
||||
} finally {
|
||||
globalThis.setTimeout = currentSetTimeout;
|
||||
globalThis.clearTimeout = currentClearTimeout;
|
||||
globalThis.setImmediate = currentSetImmediate;
|
||||
globalThis.clearImmediate = currentClearImmediate;
|
||||
if (globalThis.process) nextTick(() => {
|
||||
globalThis.process.nextTick = currentNextTick;
|
||||
});
|
||||
}
|
||||
}
|
||||
const promises = /* @__PURE__ */ new Set();
|
||||
async function rpcDone() {
|
||||
if (!promises.size) return;
|
||||
const awaitable = Array.from(promises);
|
||||
return Promise.all(awaitable);
|
||||
}
|
||||
function createRuntimeRpc(options) {
|
||||
let setCancel = (_reason) => {};
|
||||
const onCancel = new Promise((resolve) => {
|
||||
setCancel = resolve;
|
||||
});
|
||||
const rpc = createSafeRpc(createBirpc({ onCancel: setCancel }, {
|
||||
eventNames: [
|
||||
"onUserConsoleLog",
|
||||
"onCollected",
|
||||
"onCancel"
|
||||
],
|
||||
onTimeoutError(functionName, args) {
|
||||
let message = `[vitest-worker]: Timeout calling "${functionName}"`;
|
||||
if (functionName === "fetch" || functionName === "transform" || functionName === "resolveId") message += ` with "${JSON.stringify(args)}"`;
|
||||
// JSON.stringify cannot serialize Error instances
|
||||
if (functionName === "onUnhandledError") message += ` with "${args[0]?.message || args[0]}"`;
|
||||
throw new Error(message);
|
||||
},
|
||||
...options
|
||||
}));
|
||||
return {
|
||||
rpc,
|
||||
onCancel
|
||||
};
|
||||
}
|
||||
function createSafeRpc(rpc) {
|
||||
return new Proxy(rpc, { get(target, p, handler) {
|
||||
const sendCall = get(target, p, handler);
|
||||
const safeSendCall = (...args) => withSafeTimers(async () => {
|
||||
const result = sendCall(...args);
|
||||
promises.add(result);
|
||||
try {
|
||||
return await result;
|
||||
} finally {
|
||||
promises.delete(result);
|
||||
}
|
||||
});
|
||||
safeSendCall.asEvent = sendCall.asEvent;
|
||||
return safeSendCall;
|
||||
} });
|
||||
}
|
||||
function rpc() {
|
||||
const { rpc } = getWorkerState();
|
||||
return rpc;
|
||||
}
|
||||
|
||||
export { rpcDone as a, createRuntimeRpc as c, rpc as r };
|
||||
129
node_modules/vitest/dist/chunks/runBaseTests.9Ij9_de-.js
generated
vendored
Normal file
129
node_modules/vitest/dist/chunks/runBaseTests.9Ij9_de-.js
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
import { performance } from 'node:perf_hooks';
|
||||
import { startTests, collectTests } from '@vitest/runner';
|
||||
import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.CwejwG0H.js';
|
||||
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './setup-common.Dd054P77.js';
|
||||
import { a as globalExpect, v as vi } from './vi.bdSIJ99Y.js';
|
||||
import { c as closeInspector } from './inspector.C914Efll.js';
|
||||
import { createRequire } from 'node:module';
|
||||
import timers from 'node:timers';
|
||||
import timersPromises from 'node:timers/promises';
|
||||
import util from 'node:util';
|
||||
import { getSafeTimers } from '@vitest/utils';
|
||||
import { KNOWN_ASSET_TYPES } from 'vite-node/constants';
|
||||
import { installSourcemapsSupport } from 'vite-node/source-map';
|
||||
import { V as VitestIndex } from './index.CdQS2e2Q.js';
|
||||
import { g as getWorkerState, r as resetModules } from './utils.XdZDrNZV.js';
|
||||
import 'chai';
|
||||
import 'node:path';
|
||||
import '../path.js';
|
||||
import 'node:url';
|
||||
import './rpc.-pEldfrD.js';
|
||||
import './index.B521nVV-.js';
|
||||
import './coverage.DVF1vEu8.js';
|
||||
import '@vitest/snapshot';
|
||||
import '@vitest/expect';
|
||||
import '@vitest/runner/utils';
|
||||
import './_commonjsHelpers.BFTU3MAI.js';
|
||||
import '@vitest/utils/error';
|
||||
import '@vitest/spy';
|
||||
import '@vitest/utils/source-map';
|
||||
import './date.Bq6ZW5rf.js';
|
||||
import './benchmark.CYdenmiT.js';
|
||||
import 'expect-type';
|
||||
|
||||
// this should only be used in Node
|
||||
let globalSetup = false;
|
||||
async function setupGlobalEnv(config, { environment }, executor) {
|
||||
await setupCommonEnv(config);
|
||||
Object.defineProperty(globalThis, "__vitest_index__", {
|
||||
value: VitestIndex,
|
||||
enumerable: false
|
||||
});
|
||||
const state = getWorkerState();
|
||||
if (!state.config.snapshotOptions.snapshotEnvironment) state.config.snapshotOptions.snapshotEnvironment = await resolveSnapshotEnvironment(config, executor);
|
||||
if (globalSetup) return;
|
||||
globalSetup = true;
|
||||
if (environment.transformMode === "web") {
|
||||
const _require = createRequire(import.meta.url);
|
||||
// always mock "required" `css` files, because we cannot process them
|
||||
_require.extensions[".css"] = resolveCss;
|
||||
_require.extensions[".scss"] = resolveCss;
|
||||
_require.extensions[".sass"] = resolveCss;
|
||||
_require.extensions[".less"] = resolveCss;
|
||||
// since we are using Vite, we can assume how these will be resolved
|
||||
KNOWN_ASSET_TYPES.forEach((type) => {
|
||||
_require.extensions[`.${type}`] = resolveAsset;
|
||||
});
|
||||
process.env.SSR = "";
|
||||
} else process.env.SSR = "1";
|
||||
// @ts-expect-error not typed global for patched timers
|
||||
globalThis.__vitest_required__ = {
|
||||
util,
|
||||
timers,
|
||||
timersPromises
|
||||
};
|
||||
installSourcemapsSupport({ getSourceMap: (source) => state.moduleCache.getSourceMap(source) });
|
||||
if (!config.disableConsoleIntercept) await setupConsoleLogSpy();
|
||||
}
|
||||
function resolveCss(mod) {
|
||||
mod.exports = "";
|
||||
}
|
||||
function resolveAsset(mod, url) {
|
||||
mod.exports = url;
|
||||
}
|
||||
async function setupConsoleLogSpy() {
|
||||
const { createCustomConsole } = await import('./console.CtFJOzRO.js');
|
||||
globalThis.console = createCustomConsole();
|
||||
}
|
||||
async function withEnv({ environment }, options, fn) {
|
||||
// @ts-expect-error untyped global
|
||||
globalThis.__vitest_environment__ = environment.name;
|
||||
globalExpect.setState({ environment: environment.name });
|
||||
const env = await environment.setup(globalThis, options);
|
||||
try {
|
||||
await fn();
|
||||
} finally {
|
||||
// Run possible setTimeouts, e.g. the onces used by ConsoleLogSpy
|
||||
const { setTimeout } = getSafeTimers();
|
||||
await new Promise((resolve) => setTimeout(resolve));
|
||||
await env.teardown(globalThis);
|
||||
}
|
||||
}
|
||||
|
||||
// browser shouldn't call this!
|
||||
async function run(method, files, config, environment, executor) {
|
||||
const workerState = getWorkerState();
|
||||
const isIsolatedThreads = config.pool === "threads" && (config.poolOptions?.threads?.isolate ?? true);
|
||||
const isIsolatedForks = config.pool === "forks" && (config.poolOptions?.forks?.isolate ?? true);
|
||||
const isolate = isIsolatedThreads || isIsolatedForks;
|
||||
await setupGlobalEnv(config, environment, executor);
|
||||
await startCoverageInsideWorker(config.coverage, executor, { isolate });
|
||||
if (config.chaiConfig) setupChaiConfig(config.chaiConfig);
|
||||
const runner = await resolveTestRunner(config, executor);
|
||||
workerState.onCancel.then((reason) => {
|
||||
closeInspector(config);
|
||||
runner.cancel?.(reason);
|
||||
});
|
||||
workerState.durations.prepare = performance.now() - workerState.durations.prepare;
|
||||
workerState.durations.environment = performance.now();
|
||||
await withEnv(environment, environment.options || config.environmentOptions || {}, async () => {
|
||||
workerState.durations.environment = performance.now() - workerState.durations.environment;
|
||||
for (const file of files) {
|
||||
if (isolate) {
|
||||
executor.mocker.reset();
|
||||
resetModules(workerState.moduleCache, true);
|
||||
}
|
||||
workerState.filepath = file.filepath;
|
||||
if (method === "run") await startTests([file], runner);
|
||||
else await collectTests([file], runner);
|
||||
// reset after tests, because user might call `vi.setConfig` in setupFile
|
||||
vi.resetConfig();
|
||||
// mocks should not affect different files
|
||||
vi.restoreAllMocks();
|
||||
}
|
||||
await stopCoverageInsideWorker(config.coverage, executor, { isolate });
|
||||
});
|
||||
workerState.environmentTeardownRun = true;
|
||||
}
|
||||
|
||||
export { run };
|
||||
60
node_modules/vitest/dist/chunks/setup-common.Dd054P77.js
generated
vendored
Normal file
60
node_modules/vitest/dist/chunks/setup-common.Dd054P77.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
import { r as resolveCoverageProviderModule } from './coverage.DVF1vEu8.js';
|
||||
import { addSerializer } from '@vitest/snapshot';
|
||||
import { setSafeTimers } from '@vitest/utils';
|
||||
|
||||
async function startCoverageInsideWorker(options, loader, runtimeOptions) {
|
||||
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
||||
if (coverageModule) return coverageModule.startCoverage?.(runtimeOptions);
|
||||
return null;
|
||||
}
|
||||
async function takeCoverageInsideWorker(options, loader) {
|
||||
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
||||
if (coverageModule) return coverageModule.takeCoverage?.({ moduleExecutionInfo: loader.moduleExecutionInfo });
|
||||
return null;
|
||||
}
|
||||
async function stopCoverageInsideWorker(options, loader, runtimeOptions) {
|
||||
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
||||
if (coverageModule) return coverageModule.stopCoverage?.(runtimeOptions);
|
||||
return null;
|
||||
}
|
||||
|
||||
let globalSetup = false;
|
||||
async function setupCommonEnv(config) {
|
||||
setupDefines(config.defines);
|
||||
setupEnv(config.env);
|
||||
if (globalSetup) return;
|
||||
globalSetup = true;
|
||||
setSafeTimers();
|
||||
if (config.globals) (await import('./globals.DEHgCU4V.js')).registerApiGlobally();
|
||||
}
|
||||
function setupDefines(defines) {
|
||||
for (const key in defines) globalThis[key] = defines[key];
|
||||
}
|
||||
function setupEnv(env) {
|
||||
if (typeof process === "undefined") return;
|
||||
// same boolean-to-string assignment as VitestPlugin.configResolved
|
||||
const { PROD, DEV,...restEnvs } = env;
|
||||
process.env.PROD = PROD ? "1" : "";
|
||||
process.env.DEV = DEV ? "1" : "";
|
||||
for (const key in restEnvs) process.env[key] = env[key];
|
||||
}
|
||||
async function loadDiffConfig(config, executor) {
|
||||
if (typeof config.diff === "object") return config.diff;
|
||||
if (typeof config.diff !== "string") return;
|
||||
const diffModule = await executor.executeId(config.diff);
|
||||
if (diffModule && typeof diffModule.default === "object" && diffModule.default != null) return diffModule.default;
|
||||
else throw new Error(`invalid diff config file ${config.diff}. Must have a default export with config object`);
|
||||
}
|
||||
async function loadSnapshotSerializers(config, executor) {
|
||||
const files = config.snapshotSerializers;
|
||||
const snapshotSerializers = await Promise.all(files.map(async (file) => {
|
||||
const mo = await executor.executeId(file);
|
||||
if (!mo || typeof mo.default !== "object" || mo.default === null) throw new Error(`invalid snapshot serializer file ${file}. Must export a default object`);
|
||||
const config = mo.default;
|
||||
if (typeof config.test !== "function" || typeof config.serialize !== "function" && typeof config.print !== "function") throw new TypeError(`invalid snapshot serializer in ${file}. Must have a 'test' method along with either a 'serialize' or 'print' method.`);
|
||||
return config;
|
||||
}));
|
||||
snapshotSerializers.forEach((serializer) => addSerializer(serializer));
|
||||
}
|
||||
|
||||
export { stopCoverageInsideWorker as a, loadSnapshotSerializers as b, setupCommonEnv as c, loadDiffConfig as l, startCoverageInsideWorker as s, takeCoverageInsideWorker as t };
|
||||
10
node_modules/vitest/dist/chunks/suite.d.FvehnV49.d.ts
generated
vendored
Normal file
10
node_modules/vitest/dist/chunks/suite.d.FvehnV49.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Test } from '@vitest/runner';
|
||||
import { c as BenchmarkAPI, a as BenchFunction } from './benchmark.d.BwvBVTda.js';
|
||||
import { Options } from 'tinybench';
|
||||
import '@vitest/runner/utils';
|
||||
|
||||
declare function getBenchOptions(key: Test): Options;
|
||||
declare function getBenchFn(key: Test): BenchFunction;
|
||||
declare const bench: BenchmarkAPI;
|
||||
|
||||
export { getBenchOptions as a, bench as b, getBenchFn as g };
|
||||
874
node_modules/vitest/dist/chunks/typechecker.DRKU1-1g.js
generated
vendored
Normal file
874
node_modules/vitest/dist/chunks/typechecker.DRKU1-1g.js
generated
vendored
Normal file
@@ -0,0 +1,874 @@
|
||||
import nodeos__default from 'node:os';
|
||||
import { performance } from 'node:perf_hooks';
|
||||
import { TraceMap, generatedPositionFor, eachMapping } from '@vitest/utils/source-map';
|
||||
import { relative, basename, resolve, join } from 'pathe';
|
||||
import { x } from 'tinyexec';
|
||||
import { distDir } from '../path.js';
|
||||
import { getTests, generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes } from '@vitest/runner/utils';
|
||||
import '@vitest/utils';
|
||||
import { parseAstAsync } from 'vite';
|
||||
|
||||
function hasFailedSnapshot(suite) {
|
||||
return getTests(suite).some((s) => {
|
||||
return s.result?.errors?.some((e) => typeof e?.message === "string" && e.message.match(/Snapshot .* mismatched/));
|
||||
});
|
||||
}
|
||||
function convertTasksToEvents(file, onTask) {
|
||||
const packs = [];
|
||||
const events = [];
|
||||
function visit(suite) {
|
||||
onTask?.(suite);
|
||||
packs.push([
|
||||
suite.id,
|
||||
suite.result,
|
||||
suite.meta
|
||||
]);
|
||||
events.push([
|
||||
suite.id,
|
||||
"suite-prepare",
|
||||
void 0
|
||||
]);
|
||||
suite.tasks.forEach((task) => {
|
||||
if (task.type === "suite") visit(task);
|
||||
else {
|
||||
onTask?.(task);
|
||||
if (suite.mode !== "skip" && suite.mode !== "todo") {
|
||||
packs.push([
|
||||
task.id,
|
||||
task.result,
|
||||
task.meta
|
||||
]);
|
||||
events.push([
|
||||
task.id,
|
||||
"test-prepare",
|
||||
void 0
|
||||
]);
|
||||
task.annotations.forEach((annotation) => {
|
||||
events.push([
|
||||
task.id,
|
||||
"test-annotation",
|
||||
{ annotation }
|
||||
]);
|
||||
});
|
||||
events.push([
|
||||
task.id,
|
||||
"test-finished",
|
||||
void 0
|
||||
]);
|
||||
}
|
||||
}
|
||||
});
|
||||
events.push([
|
||||
suite.id,
|
||||
"suite-finished",
|
||||
void 0
|
||||
]);
|
||||
}
|
||||
visit(file);
|
||||
return {
|
||||
packs,
|
||||
events
|
||||
};
|
||||
}
|
||||
|
||||
const REGEXP_WRAP_PREFIX = "$$vitest:";
|
||||
function getOutputFile(config, reporter) {
|
||||
if (!config?.outputFile) return;
|
||||
if (typeof config.outputFile === "string") return config.outputFile;
|
||||
return config.outputFile[reporter];
|
||||
}
|
||||
/**
|
||||
* Prepares `SerializedConfig` for serialization, e.g. `node:v8.serialize`
|
||||
*/
|
||||
function wrapSerializableConfig(config) {
|
||||
let testNamePattern = config.testNamePattern;
|
||||
let defines = config.defines;
|
||||
// v8 serialize does not support regex
|
||||
if (testNamePattern && typeof testNamePattern !== "string") testNamePattern = `${REGEXP_WRAP_PREFIX}${testNamePattern.toString()}`;
|
||||
// v8 serialize drops properties with undefined value
|
||||
if (defines) defines = {
|
||||
keys: Object.keys(defines),
|
||||
original: defines
|
||||
};
|
||||
return {
|
||||
...config,
|
||||
testNamePattern,
|
||||
defines
|
||||
};
|
||||
}
|
||||
|
||||
// AST walker module for ESTree compatible trees
|
||||
|
||||
|
||||
// An ancestor walk keeps an array of ancestor nodes (including the
|
||||
// current node) and passes them to the callback as third parameter
|
||||
// (and also as state parameter when no other state is present).
|
||||
function ancestor(node, visitors, baseVisitor, state, override) {
|
||||
var ancestors = [];
|
||||
if (!baseVisitor) { baseVisitor = base
|
||||
; }(function c(node, st, override) {
|
||||
var type = override || node.type;
|
||||
var isNew = node !== ancestors[ancestors.length - 1];
|
||||
if (isNew) { ancestors.push(node); }
|
||||
baseVisitor[type](node, st, c);
|
||||
if (visitors[type]) { visitors[type](node, st || ancestors, ancestors); }
|
||||
if (isNew) { ancestors.pop(); }
|
||||
})(node, state, override);
|
||||
}
|
||||
|
||||
function skipThrough(node, st, c) { c(node, st); }
|
||||
function ignore(_node, _st, _c) {}
|
||||
|
||||
// Node walkers.
|
||||
|
||||
var base = {};
|
||||
|
||||
base.Program = base.BlockStatement = base.StaticBlock = function (node, st, c) {
|
||||
for (var i = 0, list = node.body; i < list.length; i += 1)
|
||||
{
|
||||
var stmt = list[i];
|
||||
|
||||
c(stmt, st, "Statement");
|
||||
}
|
||||
};
|
||||
base.Statement = skipThrough;
|
||||
base.EmptyStatement = ignore;
|
||||
base.ExpressionStatement = base.ParenthesizedExpression = base.ChainExpression =
|
||||
function (node, st, c) { return c(node.expression, st, "Expression"); };
|
||||
base.IfStatement = function (node, st, c) {
|
||||
c(node.test, st, "Expression");
|
||||
c(node.consequent, st, "Statement");
|
||||
if (node.alternate) { c(node.alternate, st, "Statement"); }
|
||||
};
|
||||
base.LabeledStatement = function (node, st, c) { return c(node.body, st, "Statement"); };
|
||||
base.BreakStatement = base.ContinueStatement = ignore;
|
||||
base.WithStatement = function (node, st, c) {
|
||||
c(node.object, st, "Expression");
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.SwitchStatement = function (node, st, c) {
|
||||
c(node.discriminant, st, "Expression");
|
||||
for (var i = 0, list = node.cases; i < list.length; i += 1) {
|
||||
var cs = list[i];
|
||||
|
||||
c(cs, st);
|
||||
}
|
||||
};
|
||||
base.SwitchCase = function (node, st, c) {
|
||||
if (node.test) { c(node.test, st, "Expression"); }
|
||||
for (var i = 0, list = node.consequent; i < list.length; i += 1)
|
||||
{
|
||||
var cons = list[i];
|
||||
|
||||
c(cons, st, "Statement");
|
||||
}
|
||||
};
|
||||
base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function (node, st, c) {
|
||||
if (node.argument) { c(node.argument, st, "Expression"); }
|
||||
};
|
||||
base.ThrowStatement = base.SpreadElement =
|
||||
function (node, st, c) { return c(node.argument, st, "Expression"); };
|
||||
base.TryStatement = function (node, st, c) {
|
||||
c(node.block, st, "Statement");
|
||||
if (node.handler) { c(node.handler, st); }
|
||||
if (node.finalizer) { c(node.finalizer, st, "Statement"); }
|
||||
};
|
||||
base.CatchClause = function (node, st, c) {
|
||||
if (node.param) { c(node.param, st, "Pattern"); }
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.WhileStatement = base.DoWhileStatement = function (node, st, c) {
|
||||
c(node.test, st, "Expression");
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.ForStatement = function (node, st, c) {
|
||||
if (node.init) { c(node.init, st, "ForInit"); }
|
||||
if (node.test) { c(node.test, st, "Expression"); }
|
||||
if (node.update) { c(node.update, st, "Expression"); }
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.ForInStatement = base.ForOfStatement = function (node, st, c) {
|
||||
c(node.left, st, "ForInit");
|
||||
c(node.right, st, "Expression");
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.ForInit = function (node, st, c) {
|
||||
if (node.type === "VariableDeclaration") { c(node, st); }
|
||||
else { c(node, st, "Expression"); }
|
||||
};
|
||||
base.DebuggerStatement = ignore;
|
||||
|
||||
base.FunctionDeclaration = function (node, st, c) { return c(node, st, "Function"); };
|
||||
base.VariableDeclaration = function (node, st, c) {
|
||||
for (var i = 0, list = node.declarations; i < list.length; i += 1)
|
||||
{
|
||||
var decl = list[i];
|
||||
|
||||
c(decl, st);
|
||||
}
|
||||
};
|
||||
base.VariableDeclarator = function (node, st, c) {
|
||||
c(node.id, st, "Pattern");
|
||||
if (node.init) { c(node.init, st, "Expression"); }
|
||||
};
|
||||
|
||||
base.Function = function (node, st, c) {
|
||||
if (node.id) { c(node.id, st, "Pattern"); }
|
||||
for (var i = 0, list = node.params; i < list.length; i += 1)
|
||||
{
|
||||
var param = list[i];
|
||||
|
||||
c(param, st, "Pattern");
|
||||
}
|
||||
c(node.body, st, node.expression ? "Expression" : "Statement");
|
||||
};
|
||||
|
||||
base.Pattern = function (node, st, c) {
|
||||
if (node.type === "Identifier")
|
||||
{ c(node, st, "VariablePattern"); }
|
||||
else if (node.type === "MemberExpression")
|
||||
{ c(node, st, "MemberPattern"); }
|
||||
else
|
||||
{ c(node, st); }
|
||||
};
|
||||
base.VariablePattern = ignore;
|
||||
base.MemberPattern = skipThrough;
|
||||
base.RestElement = function (node, st, c) { return c(node.argument, st, "Pattern"); };
|
||||
base.ArrayPattern = function (node, st, c) {
|
||||
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
||||
var elt = list[i];
|
||||
|
||||
if (elt) { c(elt, st, "Pattern"); }
|
||||
}
|
||||
};
|
||||
base.ObjectPattern = function (node, st, c) {
|
||||
for (var i = 0, list = node.properties; i < list.length; i += 1) {
|
||||
var prop = list[i];
|
||||
|
||||
if (prop.type === "Property") {
|
||||
if (prop.computed) { c(prop.key, st, "Expression"); }
|
||||
c(prop.value, st, "Pattern");
|
||||
} else if (prop.type === "RestElement") {
|
||||
c(prop.argument, st, "Pattern");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
base.Expression = skipThrough;
|
||||
base.ThisExpression = base.Super = base.MetaProperty = ignore;
|
||||
base.ArrayExpression = function (node, st, c) {
|
||||
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
||||
var elt = list[i];
|
||||
|
||||
if (elt) { c(elt, st, "Expression"); }
|
||||
}
|
||||
};
|
||||
base.ObjectExpression = function (node, st, c) {
|
||||
for (var i = 0, list = node.properties; i < list.length; i += 1)
|
||||
{
|
||||
var prop = list[i];
|
||||
|
||||
c(prop, st);
|
||||
}
|
||||
};
|
||||
base.FunctionExpression = base.ArrowFunctionExpression = base.FunctionDeclaration;
|
||||
base.SequenceExpression = function (node, st, c) {
|
||||
for (var i = 0, list = node.expressions; i < list.length; i += 1)
|
||||
{
|
||||
var expr = list[i];
|
||||
|
||||
c(expr, st, "Expression");
|
||||
}
|
||||
};
|
||||
base.TemplateLiteral = function (node, st, c) {
|
||||
for (var i = 0, list = node.quasis; i < list.length; i += 1)
|
||||
{
|
||||
var quasi = list[i];
|
||||
|
||||
c(quasi, st);
|
||||
}
|
||||
|
||||
for (var i$1 = 0, list$1 = node.expressions; i$1 < list$1.length; i$1 += 1)
|
||||
{
|
||||
var expr = list$1[i$1];
|
||||
|
||||
c(expr, st, "Expression");
|
||||
}
|
||||
};
|
||||
base.TemplateElement = ignore;
|
||||
base.UnaryExpression = base.UpdateExpression = function (node, st, c) {
|
||||
c(node.argument, st, "Expression");
|
||||
};
|
||||
base.BinaryExpression = base.LogicalExpression = function (node, st, c) {
|
||||
c(node.left, st, "Expression");
|
||||
c(node.right, st, "Expression");
|
||||
};
|
||||
base.AssignmentExpression = base.AssignmentPattern = function (node, st, c) {
|
||||
c(node.left, st, "Pattern");
|
||||
c(node.right, st, "Expression");
|
||||
};
|
||||
base.ConditionalExpression = function (node, st, c) {
|
||||
c(node.test, st, "Expression");
|
||||
c(node.consequent, st, "Expression");
|
||||
c(node.alternate, st, "Expression");
|
||||
};
|
||||
base.NewExpression = base.CallExpression = function (node, st, c) {
|
||||
c(node.callee, st, "Expression");
|
||||
if (node.arguments)
|
||||
{ for (var i = 0, list = node.arguments; i < list.length; i += 1)
|
||||
{
|
||||
var arg = list[i];
|
||||
|
||||
c(arg, st, "Expression");
|
||||
} }
|
||||
};
|
||||
base.MemberExpression = function (node, st, c) {
|
||||
c(node.object, st, "Expression");
|
||||
if (node.computed) { c(node.property, st, "Expression"); }
|
||||
};
|
||||
base.ExportNamedDeclaration = base.ExportDefaultDeclaration = function (node, st, c) {
|
||||
if (node.declaration)
|
||||
{ c(node.declaration, st, node.type === "ExportNamedDeclaration" || node.declaration.id ? "Statement" : "Expression"); }
|
||||
if (node.source) { c(node.source, st, "Expression"); }
|
||||
};
|
||||
base.ExportAllDeclaration = function (node, st, c) {
|
||||
if (node.exported)
|
||||
{ c(node.exported, st); }
|
||||
c(node.source, st, "Expression");
|
||||
};
|
||||
base.ImportDeclaration = function (node, st, c) {
|
||||
for (var i = 0, list = node.specifiers; i < list.length; i += 1)
|
||||
{
|
||||
var spec = list[i];
|
||||
|
||||
c(spec, st);
|
||||
}
|
||||
c(node.source, st, "Expression");
|
||||
};
|
||||
base.ImportExpression = function (node, st, c) {
|
||||
c(node.source, st, "Expression");
|
||||
};
|
||||
base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.PrivateIdentifier = base.Literal = ignore;
|
||||
|
||||
base.TaggedTemplateExpression = function (node, st, c) {
|
||||
c(node.tag, st, "Expression");
|
||||
c(node.quasi, st, "Expression");
|
||||
};
|
||||
base.ClassDeclaration = base.ClassExpression = function (node, st, c) { return c(node, st, "Class"); };
|
||||
base.Class = function (node, st, c) {
|
||||
if (node.id) { c(node.id, st, "Pattern"); }
|
||||
if (node.superClass) { c(node.superClass, st, "Expression"); }
|
||||
c(node.body, st);
|
||||
};
|
||||
base.ClassBody = function (node, st, c) {
|
||||
for (var i = 0, list = node.body; i < list.length; i += 1)
|
||||
{
|
||||
var elt = list[i];
|
||||
|
||||
c(elt, st);
|
||||
}
|
||||
};
|
||||
base.MethodDefinition = base.PropertyDefinition = base.Property = function (node, st, c) {
|
||||
if (node.computed) { c(node.key, st, "Expression"); }
|
||||
if (node.value) { c(node.value, st, "Expression"); }
|
||||
};
|
||||
|
||||
async function collectTests(ctx, filepath) {
|
||||
const request = await ctx.vitenode.transformRequest(filepath, filepath);
|
||||
if (!request) return null;
|
||||
const ast = await parseAstAsync(request.code);
|
||||
const testFilepath = relative(ctx.config.root, filepath);
|
||||
const projectName = ctx.name;
|
||||
const typecheckSubprojectName = projectName ? `${projectName}:__typecheck__` : "__typecheck__";
|
||||
const file = {
|
||||
filepath,
|
||||
type: "suite",
|
||||
id: generateHash(`${testFilepath}${typecheckSubprojectName}`),
|
||||
name: testFilepath,
|
||||
mode: "run",
|
||||
tasks: [],
|
||||
start: ast.start,
|
||||
end: ast.end,
|
||||
projectName,
|
||||
meta: { typecheck: true },
|
||||
file: null
|
||||
};
|
||||
file.file = file;
|
||||
const definitions = [];
|
||||
const getName = (callee) => {
|
||||
if (!callee) return null;
|
||||
if (callee.type === "Identifier") return callee.name;
|
||||
if (callee.type === "CallExpression") return getName(callee.callee);
|
||||
if (callee.type === "TaggedTemplateExpression") return getName(callee.tag);
|
||||
if (callee.type === "MemberExpression") {
|
||||
if (callee.object?.type === "Identifier" && [
|
||||
"it",
|
||||
"test",
|
||||
"describe",
|
||||
"suite"
|
||||
].includes(callee.object.name)) return callee.object?.name;
|
||||
// direct call as `__vite_ssr_exports_0__.test()`
|
||||
if (callee.object?.name?.startsWith("__vite_ssr_")) return getName(callee.property);
|
||||
// call as `__vite_ssr__.test.skip()`
|
||||
return getName(callee.object?.property);
|
||||
}
|
||||
// unwrap (0, ...)
|
||||
if (callee.type === "SequenceExpression" && callee.expressions.length === 2) {
|
||||
const [e0, e1] = callee.expressions;
|
||||
if (e0.type === "Literal" && e0.value === 0) return getName(e1);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
ancestor(ast, { CallExpression(node) {
|
||||
const { callee } = node;
|
||||
const name = getName(callee);
|
||||
if (!name) return;
|
||||
if (![
|
||||
"it",
|
||||
"test",
|
||||
"describe",
|
||||
"suite"
|
||||
].includes(name)) return;
|
||||
const property = callee?.property?.name;
|
||||
let mode = !property || property === name ? "run" : property;
|
||||
// they will be picked up in the next iteration
|
||||
if ([
|
||||
"each",
|
||||
"for",
|
||||
"skipIf",
|
||||
"runIf"
|
||||
].includes(mode)) return;
|
||||
let start;
|
||||
const end = node.end;
|
||||
// .each
|
||||
if (callee.type === "CallExpression") start = callee.end;
|
||||
else if (callee.type === "TaggedTemplateExpression") start = callee.end + 1;
|
||||
else start = node.start;
|
||||
const { arguments: [messageNode] } = node;
|
||||
const isQuoted = messageNode?.type === "Literal" || messageNode?.type === "TemplateLiteral";
|
||||
const message = isQuoted ? request.code.slice(messageNode.start + 1, messageNode.end - 1) : request.code.slice(messageNode.start, messageNode.end);
|
||||
// cannot statically analyze, so we always skip it
|
||||
if (mode === "skipIf" || mode === "runIf") mode = "skip";
|
||||
definitions.push({
|
||||
start,
|
||||
end,
|
||||
name: message,
|
||||
type: name === "it" || name === "test" ? "test" : "suite",
|
||||
mode,
|
||||
task: null
|
||||
});
|
||||
} });
|
||||
let lastSuite = file;
|
||||
const updateLatestSuite = (index) => {
|
||||
while (lastSuite.suite && lastSuite.end < index) lastSuite = lastSuite.suite;
|
||||
return lastSuite;
|
||||
};
|
||||
definitions.sort((a, b) => a.start - b.start).forEach((definition) => {
|
||||
const latestSuite = updateLatestSuite(definition.start);
|
||||
let mode = definition.mode;
|
||||
if (latestSuite.mode !== "run")
|
||||
// inherit suite mode, if it's set
|
||||
mode = latestSuite.mode;
|
||||
if (definition.type === "suite") {
|
||||
const task = {
|
||||
type: definition.type,
|
||||
id: "",
|
||||
suite: latestSuite,
|
||||
file,
|
||||
tasks: [],
|
||||
mode,
|
||||
name: definition.name,
|
||||
end: definition.end,
|
||||
start: definition.start,
|
||||
meta: { typecheck: true }
|
||||
};
|
||||
definition.task = task;
|
||||
latestSuite.tasks.push(task);
|
||||
lastSuite = task;
|
||||
return;
|
||||
}
|
||||
const task = {
|
||||
type: definition.type,
|
||||
id: "",
|
||||
suite: latestSuite,
|
||||
file,
|
||||
mode,
|
||||
timeout: 0,
|
||||
context: {},
|
||||
name: definition.name,
|
||||
end: definition.end,
|
||||
start: definition.start,
|
||||
annotations: [],
|
||||
meta: { typecheck: true }
|
||||
};
|
||||
definition.task = task;
|
||||
latestSuite.tasks.push(task);
|
||||
});
|
||||
calculateSuiteHash(file);
|
||||
const hasOnly = someTasksAreOnly(file);
|
||||
interpretTaskModes(file, ctx.config.testNamePattern, void 0, hasOnly, false, ctx.config.allowOnly);
|
||||
return {
|
||||
file,
|
||||
parsed: request.code,
|
||||
filepath,
|
||||
map: request.map,
|
||||
definitions
|
||||
};
|
||||
}
|
||||
|
||||
const newLineRegExp = /\r?\n/;
|
||||
const errCodeRegExp = /error TS(?<errCode>\d+)/;
|
||||
async function makeTscErrorInfo(errInfo) {
|
||||
const [errFilePathPos = "", ...errMsgRawArr] = errInfo.split(":");
|
||||
if (!errFilePathPos || errMsgRawArr.length === 0 || errMsgRawArr.join("").length === 0) return ["unknown filepath", null];
|
||||
const errMsgRaw = errMsgRawArr.join("").trim();
|
||||
// get filePath, line, col
|
||||
const [errFilePath, errPos] = errFilePathPos.slice(0, -1).split("(");
|
||||
if (!errFilePath || !errPos) return ["unknown filepath", null];
|
||||
const [errLine, errCol] = errPos.split(",");
|
||||
if (!errLine || !errCol) return [errFilePath, null];
|
||||
// get errCode, errMsg
|
||||
const execArr = errCodeRegExp.exec(errMsgRaw);
|
||||
if (!execArr) return [errFilePath, null];
|
||||
const errCodeStr = execArr.groups?.errCode ?? "";
|
||||
if (!errCodeStr) return [errFilePath, null];
|
||||
const line = Number(errLine);
|
||||
const col = Number(errCol);
|
||||
const errCode = Number(errCodeStr);
|
||||
return [errFilePath, {
|
||||
filePath: errFilePath,
|
||||
errCode,
|
||||
line,
|
||||
column: col,
|
||||
errMsg: errMsgRaw.slice(`error TS${errCode} `.length)
|
||||
}];
|
||||
}
|
||||
async function getRawErrsMapFromTsCompile(tscErrorStdout) {
|
||||
const rawErrsMap = /* @__PURE__ */ new Map();
|
||||
// Merge details line with main line (i.e. which contains file path)
|
||||
const infos = await Promise.all(tscErrorStdout.split(newLineRegExp).reduce((prev, next) => {
|
||||
if (!next) return prev;
|
||||
else if (!next.startsWith(" ")) prev.push(next);
|
||||
else prev[prev.length - 1] += `\n${next}`;
|
||||
return prev;
|
||||
}, []).map((errInfoLine) => makeTscErrorInfo(errInfoLine)));
|
||||
infos.forEach(([errFilePath, errInfo]) => {
|
||||
if (!errInfo) return;
|
||||
if (!rawErrsMap.has(errFilePath)) rawErrsMap.set(errFilePath, [errInfo]);
|
||||
else rawErrsMap.get(errFilePath)?.push(errInfo);
|
||||
});
|
||||
return rawErrsMap;
|
||||
}
|
||||
|
||||
function createIndexMap(source) {
|
||||
const map = /* @__PURE__ */ new Map();
|
||||
let index = 0;
|
||||
let line = 1;
|
||||
let column = 1;
|
||||
for (const char of source) {
|
||||
map.set(`${line}:${column}`, index++);
|
||||
if (char === "\n" || char === "\r\n") {
|
||||
line++;
|
||||
column = 0;
|
||||
} else column++;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
class TypeCheckError extends Error {
|
||||
name = "TypeCheckError";
|
||||
constructor(message, stacks) {
|
||||
super(message);
|
||||
this.message = message;
|
||||
this.stacks = stacks;
|
||||
}
|
||||
}
|
||||
class Typechecker {
|
||||
_onParseStart;
|
||||
_onParseEnd;
|
||||
_onWatcherRerun;
|
||||
_result = {
|
||||
files: [],
|
||||
sourceErrors: [],
|
||||
time: 0
|
||||
};
|
||||
_startTime = 0;
|
||||
_output = "";
|
||||
_tests = {};
|
||||
process;
|
||||
files = [];
|
||||
constructor(project) {
|
||||
this.project = project;
|
||||
}
|
||||
setFiles(files) {
|
||||
this.files = files;
|
||||
}
|
||||
onParseStart(fn) {
|
||||
this._onParseStart = fn;
|
||||
}
|
||||
onParseEnd(fn) {
|
||||
this._onParseEnd = fn;
|
||||
}
|
||||
onWatcherRerun(fn) {
|
||||
this._onWatcherRerun = fn;
|
||||
}
|
||||
async collectFileTests(filepath) {
|
||||
return collectTests(this.project, filepath);
|
||||
}
|
||||
getFiles() {
|
||||
return this.files;
|
||||
}
|
||||
async collectTests() {
|
||||
const tests = (await Promise.all(this.getFiles().map((filepath) => this.collectFileTests(filepath)))).reduce((acc, data) => {
|
||||
if (!data) return acc;
|
||||
acc[data.filepath] = data;
|
||||
return acc;
|
||||
}, {});
|
||||
this._tests = tests;
|
||||
return tests;
|
||||
}
|
||||
markPassed(file) {
|
||||
if (!file.result?.state) file.result = { state: "pass" };
|
||||
const markTasks = (tasks) => {
|
||||
for (const task of tasks) {
|
||||
if ("tasks" in task) markTasks(task.tasks);
|
||||
if (!task.result?.state && (task.mode === "run" || task.mode === "queued")) task.result = { state: "pass" };
|
||||
}
|
||||
};
|
||||
markTasks(file.tasks);
|
||||
}
|
||||
async prepareResults(output) {
|
||||
const typeErrors = await this.parseTscLikeOutput(output);
|
||||
const testFiles = new Set(this.getFiles());
|
||||
if (!this._tests) this._tests = await this.collectTests();
|
||||
const sourceErrors = [];
|
||||
const files = [];
|
||||
testFiles.forEach((path) => {
|
||||
const { file, definitions, map, parsed } = this._tests[path];
|
||||
const errors = typeErrors.get(path);
|
||||
files.push(file);
|
||||
if (!errors) {
|
||||
this.markPassed(file);
|
||||
return;
|
||||
}
|
||||
const sortedDefinitions = [...definitions.sort((a, b) => b.start - a.start)];
|
||||
// has no map for ".js" files that use // @ts-check
|
||||
const traceMap = map && new TraceMap(map);
|
||||
const indexMap = createIndexMap(parsed);
|
||||
const markState = (task, state) => {
|
||||
task.result = { state: task.mode === "run" || task.mode === "only" ? state : task.mode };
|
||||
if (task.suite) markState(task.suite, state);
|
||||
else if (task.file && task !== task.file) markState(task.file, state);
|
||||
};
|
||||
errors.forEach(({ error, originalError }) => {
|
||||
const processedPos = traceMap ? findGeneratedPosition(traceMap, {
|
||||
line: originalError.line,
|
||||
column: originalError.column,
|
||||
source: basename(path)
|
||||
}) : originalError;
|
||||
const line = processedPos.line ?? originalError.line;
|
||||
const column = processedPos.column ?? originalError.column;
|
||||
const index = indexMap.get(`${line}:${column}`);
|
||||
const definition = index != null && sortedDefinitions.find((def) => def.start <= index && def.end >= index);
|
||||
const suite = definition ? definition.task : file;
|
||||
const state = suite.mode === "run" || suite.mode === "only" ? "fail" : suite.mode;
|
||||
const errors = suite.result?.errors || [];
|
||||
suite.result = {
|
||||
state,
|
||||
errors
|
||||
};
|
||||
errors.push(error);
|
||||
if (state === "fail") {
|
||||
if (suite.suite) markState(suite.suite, "fail");
|
||||
else if (suite.file && suite !== suite.file) markState(suite.file, "fail");
|
||||
}
|
||||
});
|
||||
this.markPassed(file);
|
||||
});
|
||||
typeErrors.forEach((errors, path) => {
|
||||
if (!testFiles.has(path)) sourceErrors.push(...errors.map(({ error }) => error));
|
||||
});
|
||||
return {
|
||||
files,
|
||||
sourceErrors,
|
||||
time: performance.now() - this._startTime
|
||||
};
|
||||
}
|
||||
async parseTscLikeOutput(output) {
|
||||
const errorsMap = await getRawErrsMapFromTsCompile(output);
|
||||
const typesErrors = /* @__PURE__ */ new Map();
|
||||
errorsMap.forEach((errors, path) => {
|
||||
const filepath = resolve(this.project.config.root, path);
|
||||
const suiteErrors = errors.map((info) => {
|
||||
const limit = Error.stackTraceLimit;
|
||||
Error.stackTraceLimit = 0;
|
||||
// Some expect-type errors have the most useful information on the second line e.g. `This expression is not callable.\n Type 'ExpectString<number>' has no call signatures.`
|
||||
const errMsg = info.errMsg.replace(/\r?\n\s*(Type .* has no call signatures)/g, " $1");
|
||||
const error = new TypeCheckError(errMsg, [{
|
||||
file: filepath,
|
||||
line: info.line,
|
||||
column: info.column,
|
||||
method: ""
|
||||
}]);
|
||||
Error.stackTraceLimit = limit;
|
||||
return {
|
||||
originalError: info,
|
||||
error: {
|
||||
name: error.name,
|
||||
message: errMsg,
|
||||
stacks: error.stacks,
|
||||
stack: ""
|
||||
}
|
||||
};
|
||||
});
|
||||
typesErrors.set(filepath, suiteErrors);
|
||||
});
|
||||
return typesErrors;
|
||||
}
|
||||
async stop() {
|
||||
this.process?.kill();
|
||||
this.process = void 0;
|
||||
}
|
||||
async ensurePackageInstalled(ctx, checker) {
|
||||
if (checker !== "tsc" && checker !== "vue-tsc") return;
|
||||
const packageName = checker === "tsc" ? "typescript" : "vue-tsc";
|
||||
await ctx.packageInstaller.ensureInstalled(packageName, ctx.config.root);
|
||||
}
|
||||
getExitCode() {
|
||||
return this.process?.exitCode != null && this.process.exitCode;
|
||||
}
|
||||
getOutput() {
|
||||
return this._output;
|
||||
}
|
||||
async spawn() {
|
||||
const { root, watch, typecheck } = this.project.config;
|
||||
const args = [
|
||||
"--noEmit",
|
||||
"--pretty",
|
||||
"false",
|
||||
"--incremental",
|
||||
"--tsBuildInfoFile",
|
||||
join(process.versions.pnp ? join(nodeos__default.tmpdir(), this.project.hash) : distDir, "tsconfig.tmp.tsbuildinfo")
|
||||
];
|
||||
// use builtin watcher because it's faster
|
||||
if (watch) args.push("--watch");
|
||||
if (typecheck.allowJs) args.push("--allowJs", "--checkJs");
|
||||
if (typecheck.tsconfig) args.push("-p", resolve(root, typecheck.tsconfig));
|
||||
this._output = "";
|
||||
this._startTime = performance.now();
|
||||
const child = x(typecheck.checker, args, {
|
||||
nodeOptions: {
|
||||
cwd: root,
|
||||
stdio: "pipe"
|
||||
},
|
||||
throwOnError: false
|
||||
});
|
||||
this.process = child.process;
|
||||
let rerunTriggered = false;
|
||||
let dataReceived = false;
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!child.process || !child.process.stdout) {
|
||||
reject(new Error(`Failed to initialize ${typecheck.checker}. This is a bug in Vitest - please, open an issue with reproduction.`));
|
||||
return;
|
||||
}
|
||||
child.process.stdout.on("data", (chunk) => {
|
||||
dataReceived = true;
|
||||
this._output += chunk;
|
||||
if (!watch) return;
|
||||
if (this._output.includes("File change detected") && !rerunTriggered) {
|
||||
this._onWatcherRerun?.();
|
||||
this._startTime = performance.now();
|
||||
this._result.sourceErrors = [];
|
||||
this._result.files = [];
|
||||
this._tests = null;
|
||||
rerunTriggered = true;
|
||||
}
|
||||
if (/Found \w+ errors*. Watching for/.test(this._output)) {
|
||||
rerunTriggered = false;
|
||||
this.prepareResults(this._output).then((result) => {
|
||||
this._result = result;
|
||||
this._onParseEnd?.(result);
|
||||
});
|
||||
this._output = "";
|
||||
}
|
||||
});
|
||||
const timeout = setTimeout(() => reject(new Error(`${typecheck.checker} spawn timed out`)), this.project.config.typecheck.spawnTimeout);
|
||||
function onError(cause) {
|
||||
clearTimeout(timeout);
|
||||
reject(new Error("Spawning typechecker failed - is typescript installed?", { cause }));
|
||||
}
|
||||
child.process.once("spawn", () => {
|
||||
this._onParseStart?.();
|
||||
child.process?.off("error", onError);
|
||||
clearTimeout(timeout);
|
||||
if (process.platform === "win32")
|
||||
// on Windows, the process might be spawned but fail to start
|
||||
// we wait for a potential error here. if "close" event didn't trigger,
|
||||
// we resolve the promise
|
||||
setTimeout(() => {
|
||||
resolve({ result: child });
|
||||
}, 200);
|
||||
else resolve({ result: child });
|
||||
});
|
||||
if (process.platform === "win32") child.process.once("close", (code) => {
|
||||
if (code != null && code !== 0 && !dataReceived) onError(new Error(`The ${typecheck.checker} command exited with code ${code}.`));
|
||||
});
|
||||
child.process.once("error", onError);
|
||||
});
|
||||
}
|
||||
async start() {
|
||||
if (this.process) return;
|
||||
const { watch } = this.project.config;
|
||||
const { result: child } = await this.spawn();
|
||||
if (!watch) {
|
||||
await child;
|
||||
this._result = await this.prepareResults(this._output);
|
||||
await this._onParseEnd?.(this._result);
|
||||
}
|
||||
}
|
||||
getResult() {
|
||||
return this._result;
|
||||
}
|
||||
getTestFiles() {
|
||||
return Object.values(this._tests || {}).map((i) => i.file);
|
||||
}
|
||||
getTestPacksAndEvents() {
|
||||
const packs = [];
|
||||
const events = [];
|
||||
for (const { file } of Object.values(this._tests || {})) {
|
||||
const result = convertTasksToEvents(file);
|
||||
packs.push(...result.packs);
|
||||
events.push(...result.events);
|
||||
}
|
||||
return {
|
||||
packs,
|
||||
events
|
||||
};
|
||||
}
|
||||
}
|
||||
function findGeneratedPosition(traceMap, { line, column, source }) {
|
||||
const found = generatedPositionFor(traceMap, {
|
||||
line,
|
||||
column,
|
||||
source
|
||||
});
|
||||
if (found.line !== null) return found;
|
||||
// find the next source token position when the exact error position doesn't exist in source map.
|
||||
// this can happen, for example, when the type error is in the comment "// @ts-expect-error"
|
||||
// and comments are stripped away in the generated code.
|
||||
const mappings = [];
|
||||
eachMapping(traceMap, (m) => {
|
||||
if (m.source === source && m.originalLine !== null && m.originalColumn !== null && (line === m.originalLine ? column < m.originalColumn : line < m.originalLine)) mappings.push(m);
|
||||
});
|
||||
const next = mappings.sort((a, b) => a.originalLine === b.originalLine ? a.originalColumn - b.originalColumn : a.originalLine - b.originalLine).at(0);
|
||||
if (next) return {
|
||||
line: next.generatedLine,
|
||||
column: next.generatedColumn
|
||||
};
|
||||
return {
|
||||
line: null,
|
||||
column: null
|
||||
};
|
||||
}
|
||||
|
||||
export { TypeCheckError as T, Typechecker as a, convertTasksToEvents as c, getOutputFile as g, hasFailedSnapshot as h, wrapSerializableConfig as w };
|
||||
61
node_modules/vitest/dist/chunks/utils.CAioKnHs.js
generated
vendored
Normal file
61
node_modules/vitest/dist/chunks/utils.CAioKnHs.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
import { parseRegexp } from '@vitest/utils';
|
||||
|
||||
const REGEXP_WRAP_PREFIX = "$$vitest:";
|
||||
// Store global APIs in case process is overwritten by tests
|
||||
const processSend = process.send?.bind(process);
|
||||
const processOn = process.on?.bind(process);
|
||||
const processOff = process.off?.bind(process);
|
||||
const dispose = [];
|
||||
function createThreadsRpcOptions({ port }) {
|
||||
return {
|
||||
post: (v) => {
|
||||
port.postMessage(v);
|
||||
},
|
||||
on: (fn) => {
|
||||
port.addListener("message", fn);
|
||||
}
|
||||
};
|
||||
}
|
||||
function disposeInternalListeners() {
|
||||
for (const fn of dispose) try {
|
||||
fn();
|
||||
} catch {}
|
||||
dispose.length = 0;
|
||||
}
|
||||
function createForksRpcOptions(nodeV8) {
|
||||
return {
|
||||
serialize: nodeV8.serialize,
|
||||
deserialize: (v) => nodeV8.deserialize(Buffer.from(v)),
|
||||
post(v) {
|
||||
processSend(v);
|
||||
},
|
||||
on(fn) {
|
||||
const handler = (message, ...extras) => {
|
||||
// Do not react on Tinypool's internal messaging
|
||||
if (message?.__tinypool_worker_message__) return;
|
||||
return fn(message, ...extras);
|
||||
};
|
||||
processOn("message", handler);
|
||||
dispose.push(() => processOff("message", handler));
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Reverts the wrapping done by `utils/config-helpers.ts`'s `wrapSerializableConfig`
|
||||
*/
|
||||
function unwrapSerializableConfig(config) {
|
||||
if (config.testNamePattern && typeof config.testNamePattern === "string") {
|
||||
const testNamePattern = config.testNamePattern;
|
||||
if (testNamePattern.startsWith(REGEXP_WRAP_PREFIX)) config.testNamePattern = parseRegexp(testNamePattern.slice(REGEXP_WRAP_PREFIX.length));
|
||||
}
|
||||
if (config.defines && Array.isArray(config.defines.keys) && config.defines.original) {
|
||||
const { keys, original } = config.defines;
|
||||
const defines = {};
|
||||
// Apply all keys from the original. Entries which had undefined value are missing from original now
|
||||
for (const key of keys) defines[key] = original[key];
|
||||
config.defines = defines;
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
export { createThreadsRpcOptions as a, createForksRpcOptions as c, disposeInternalListeners as d, unwrapSerializableConfig as u };
|
||||
65
node_modules/vitest/dist/chunks/utils.XdZDrNZV.js
generated
vendored
Normal file
65
node_modules/vitest/dist/chunks/utils.XdZDrNZV.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
import { getSafeTimers } from '@vitest/utils';
|
||||
|
||||
const NAME_WORKER_STATE = "__vitest_worker__";
|
||||
function getWorkerState() {
|
||||
// @ts-expect-error untyped global
|
||||
const workerState = globalThis[NAME_WORKER_STATE];
|
||||
if (!workerState) {
|
||||
const errorMsg = "Vitest failed to access its internal state.\n\nOne of the following is possible:\n- \"vitest\" is imported directly without running \"vitest\" command\n- \"vitest\" is imported inside \"globalSetup\" (to fix this, use \"setupFiles\" instead, because \"globalSetup\" runs in a different context)\n- \"vitest\" is imported inside Vite / Vitest config file\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n";
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
return workerState;
|
||||
}
|
||||
function provideWorkerState(context, state) {
|
||||
Object.defineProperty(context, NAME_WORKER_STATE, {
|
||||
value: state,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
enumerable: false
|
||||
});
|
||||
return state;
|
||||
}
|
||||
function getCurrentEnvironment() {
|
||||
const state = getWorkerState();
|
||||
return state?.environment.name;
|
||||
}
|
||||
function isChildProcess() {
|
||||
return typeof process !== "undefined" && !!process.send;
|
||||
}
|
||||
function setProcessTitle(title) {
|
||||
try {
|
||||
process.title = `node (${title})`;
|
||||
} catch {}
|
||||
}
|
||||
function resetModules(modules, resetMocks = false) {
|
||||
const skipPaths = [
|
||||
/\/vitest\/dist\//,
|
||||
/\/vite-node\/dist\//,
|
||||
/vitest-virtual-\w+\/dist/,
|
||||
/@vitest\/dist/,
|
||||
...!resetMocks ? [/^mock:/] : []
|
||||
];
|
||||
modules.forEach((mod, path) => {
|
||||
if (skipPaths.some((re) => re.test(path))) return;
|
||||
modules.invalidateModule(mod);
|
||||
});
|
||||
}
|
||||
function waitNextTick() {
|
||||
const { setTimeout } = getSafeTimers();
|
||||
return new Promise((resolve) => setTimeout(resolve, 0));
|
||||
}
|
||||
async function waitForImportsToResolve() {
|
||||
await waitNextTick();
|
||||
const state = getWorkerState();
|
||||
const promises = [];
|
||||
let resolvingCount = 0;
|
||||
for (const mod of state.moduleCache.values()) {
|
||||
if (mod.promise && !mod.evaluated) promises.push(mod.promise);
|
||||
if (mod.resolving) resolvingCount++;
|
||||
}
|
||||
if (!promises.length && !resolvingCount) return;
|
||||
await Promise.allSettled(promises);
|
||||
await waitForImportsToResolve();
|
||||
}
|
||||
|
||||
export { getCurrentEnvironment as a, getWorkerState as g, isChildProcess as i, provideWorkerState as p, resetModules as r, setProcessTitle as s, waitForImportsToResolve as w };
|
||||
4015
node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js
generated
vendored
Normal file
4015
node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
25
node_modules/vitest/dist/chunks/vite.d.BnOPPc46.d.ts
generated
vendored
Normal file
25
node_modules/vitest/dist/chunks/vite.d.BnOPPc46.d.ts
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import { HookHandler } from 'vite';
|
||||
import { V as Vitest, T as TestProject, b as TestProjectConfiguration, I as InlineConfig } from './reporters.d.BuRON0I0.js';
|
||||
|
||||
interface VitestPluginContext {
|
||||
vitest: Vitest;
|
||||
project: TestProject;
|
||||
injectTestProjects: (config: TestProjectConfiguration | TestProjectConfiguration[]) => Promise<TestProject[]>;
|
||||
}
|
||||
|
||||
/* eslint-disable unused-imports/no-unused-vars */
|
||||
|
||||
type VitestInlineConfig = InlineConfig;
|
||||
declare module "vite" {
|
||||
interface UserConfig {
|
||||
/**
|
||||
* Options for Vitest
|
||||
*/
|
||||
test?: VitestInlineConfig;
|
||||
}
|
||||
interface Plugin<A = any> {
|
||||
configureVitest?: HookHandler<(context: VitestPluginContext) => void>;
|
||||
}
|
||||
}
|
||||
|
||||
export type { VitestPluginContext as V };
|
||||
756
node_modules/vitest/dist/chunks/vm.BThCzidc.js
generated
vendored
Normal file
756
node_modules/vitest/dist/chunks/vm.BThCzidc.js
generated
vendored
Normal file
@@ -0,0 +1,756 @@
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||
import vm, { isContext } from 'node:vm';
|
||||
import { dirname, basename, extname, normalize, join, resolve } from 'pathe';
|
||||
import { distDir } from '../path.js';
|
||||
import { createCustomConsole } from './console.CtFJOzRO.js';
|
||||
import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.B7h3T_Hc.js';
|
||||
import fs from 'node:fs';
|
||||
import { dirname as dirname$1 } from 'node:path';
|
||||
import { isPrimitive, isNodeBuiltin, toArray, getCachedData, setCacheData, isBareImport } from 'vite-node/utils';
|
||||
import { createRequire, Module } from 'node:module';
|
||||
import { CSS_LANGS_RE, KNOWN_ASSET_RE } from 'vite-node/constants';
|
||||
import { p as provideWorkerState } from './utils.XdZDrNZV.js';
|
||||
|
||||
function interopCommonJsModule(interopDefault, mod) {
|
||||
if (isPrimitive(mod) || Array.isArray(mod) || mod instanceof Promise) return {
|
||||
keys: [],
|
||||
moduleExports: {},
|
||||
defaultExport: mod
|
||||
};
|
||||
if (interopDefault !== false && "__esModule" in mod && !isPrimitive(mod.default)) {
|
||||
const defaultKets = Object.keys(mod.default);
|
||||
const moduleKeys = Object.keys(mod);
|
||||
const allKeys = new Set([...defaultKets, ...moduleKeys]);
|
||||
allKeys.delete("default");
|
||||
return {
|
||||
keys: Array.from(allKeys),
|
||||
moduleExports: new Proxy(mod, { get(mod, prop) {
|
||||
return mod[prop] ?? mod.default?.[prop];
|
||||
} }),
|
||||
defaultExport: mod
|
||||
};
|
||||
}
|
||||
return {
|
||||
keys: Object.keys(mod).filter((key) => key !== "default"),
|
||||
moduleExports: mod,
|
||||
defaultExport: mod
|
||||
};
|
||||
}
|
||||
const SyntheticModule = vm.SyntheticModule;
|
||||
const SourceTextModule = vm.SourceTextModule;
|
||||
|
||||
const _require = createRequire(import.meta.url);
|
||||
const requiresCache = /* @__PURE__ */ new WeakMap();
|
||||
class CommonjsExecutor {
|
||||
context;
|
||||
requireCache = /* @__PURE__ */ new Map();
|
||||
publicRequireCache = this.createProxyCache();
|
||||
moduleCache = /* @__PURE__ */ new Map();
|
||||
builtinCache = Object.create(null);
|
||||
extensions = Object.create(null);
|
||||
fs;
|
||||
Module;
|
||||
interopDefault;
|
||||
constructor(options) {
|
||||
this.context = options.context;
|
||||
this.fs = options.fileMap;
|
||||
this.interopDefault = options.interopDefault;
|
||||
const primitives = vm.runInContext("({ Object, Array, Error })", this.context);
|
||||
// eslint-disable-next-line ts/no-this-alias
|
||||
const executor = this;
|
||||
this.Module = class Module$1 {
|
||||
exports;
|
||||
isPreloading = false;
|
||||
id;
|
||||
filename;
|
||||
loaded;
|
||||
parent;
|
||||
children = [];
|
||||
path;
|
||||
paths = [];
|
||||
constructor(id = "", parent) {
|
||||
this.exports = primitives.Object.create(Object.prototype);
|
||||
// in our case the path should always be resolved already
|
||||
this.path = dirname(id);
|
||||
this.id = id;
|
||||
this.filename = id;
|
||||
this.loaded = false;
|
||||
this.parent = parent;
|
||||
}
|
||||
get require() {
|
||||
const require = requiresCache.get(this);
|
||||
if (require) return require;
|
||||
const _require = Module$1.createRequire(this.id);
|
||||
requiresCache.set(this, _require);
|
||||
return _require;
|
||||
}
|
||||
static register = () => {
|
||||
throw new Error(`[vitest] "register" is not available when running in Vitest.`);
|
||||
};
|
||||
static registerHooks = () => {
|
||||
throw new Error(`[vitest] "registerHooks" is not available when running in Vitest.`);
|
||||
};
|
||||
_compile(code, filename) {
|
||||
const cjsModule = Module$1.wrap(code);
|
||||
const script = new vm.Script(cjsModule, {
|
||||
filename,
|
||||
importModuleDynamically: options.importModuleDynamically
|
||||
});
|
||||
// @ts-expect-error mark script with current identifier
|
||||
script.identifier = filename;
|
||||
const fn = script.runInContext(executor.context);
|
||||
const __dirname = dirname(filename);
|
||||
executor.requireCache.set(filename, this);
|
||||
try {
|
||||
fn(this.exports, this.require, this, filename, __dirname);
|
||||
return this.exports;
|
||||
} finally {
|
||||
this.loaded = true;
|
||||
}
|
||||
}
|
||||
// exposed for external use, Node.js does the opposite
|
||||
static _load = (request, parent, _isMain) => {
|
||||
const require = Module$1.createRequire(parent?.filename ?? request);
|
||||
return require(request);
|
||||
};
|
||||
static wrap = (script) => {
|
||||
return Module$1.wrapper[0] + script + Module$1.wrapper[1];
|
||||
};
|
||||
static wrapper = new primitives.Array("(function (exports, require, module, __filename, __dirname) { ", "\n});");
|
||||
static builtinModules = Module.builtinModules;
|
||||
static findSourceMap = Module.findSourceMap;
|
||||
static SourceMap = Module.SourceMap;
|
||||
static syncBuiltinESMExports = Module.syncBuiltinESMExports;
|
||||
static _cache = executor.publicRequireCache;
|
||||
static _extensions = executor.extensions;
|
||||
static createRequire = (filename) => {
|
||||
return executor.createRequire(filename);
|
||||
};
|
||||
static runMain = () => {
|
||||
throw new primitives.Error("[vitest] \"runMain\" is not implemented.");
|
||||
};
|
||||
// @ts-expect-error not typed
|
||||
static _resolveFilename = Module._resolveFilename;
|
||||
// @ts-expect-error not typed
|
||||
static _findPath = Module._findPath;
|
||||
// @ts-expect-error not typed
|
||||
static _initPaths = Module._initPaths;
|
||||
// @ts-expect-error not typed
|
||||
static _preloadModules = Module._preloadModules;
|
||||
// @ts-expect-error not typed
|
||||
static _resolveLookupPaths = Module._resolveLookupPaths;
|
||||
// @ts-expect-error not typed
|
||||
static globalPaths = Module.globalPaths;
|
||||
static isBuiltin = Module.isBuiltin;
|
||||
static constants = Module.constants;
|
||||
static enableCompileCache = Module.enableCompileCache;
|
||||
static getCompileCacheDir = Module.getCompileCacheDir;
|
||||
static flushCompileCache = Module.flushCompileCache;
|
||||
static stripTypeScriptTypes = Module.stripTypeScriptTypes;
|
||||
static findPackageJSON = Module.findPackageJSON;
|
||||
static Module = Module$1;
|
||||
};
|
||||
this.extensions[".js"] = this.requireJs;
|
||||
this.extensions[".json"] = this.requireJson;
|
||||
}
|
||||
requireJs = (m, filename) => {
|
||||
const content = this.fs.readFile(filename);
|
||||
m._compile(content, filename);
|
||||
};
|
||||
requireJson = (m, filename) => {
|
||||
const code = this.fs.readFile(filename);
|
||||
m.exports = JSON.parse(code);
|
||||
};
|
||||
createRequire = (filename) => {
|
||||
const _require = createRequire(filename);
|
||||
const require = (id) => {
|
||||
const resolved = _require.resolve(id);
|
||||
const ext = extname(resolved);
|
||||
if (ext === ".node" || isNodeBuiltin(resolved)) return this.requireCoreModule(resolved);
|
||||
const module = new this.Module(resolved);
|
||||
return this.loadCommonJSModule(module, resolved);
|
||||
};
|
||||
require.resolve = _require.resolve;
|
||||
Object.defineProperty(require, "extensions", {
|
||||
get: () => this.extensions,
|
||||
set: () => {},
|
||||
configurable: true
|
||||
});
|
||||
require.main = void 0;
|
||||
require.cache = this.publicRequireCache;
|
||||
return require;
|
||||
};
|
||||
createProxyCache() {
|
||||
return new Proxy(Object.create(null), {
|
||||
defineProperty: () => true,
|
||||
deleteProperty: () => true,
|
||||
set: () => true,
|
||||
get: (_, key) => this.requireCache.get(key),
|
||||
has: (_, key) => this.requireCache.has(key),
|
||||
ownKeys: () => Array.from(this.requireCache.keys()),
|
||||
getOwnPropertyDescriptor() {
|
||||
return {
|
||||
configurable: true,
|
||||
enumerable: true
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
// very naive implementation for Node.js require
|
||||
loadCommonJSModule(module, filename) {
|
||||
const cached = this.requireCache.get(filename);
|
||||
if (cached) return cached.exports;
|
||||
const extension = this.findLongestRegisteredExtension(filename);
|
||||
const loader = this.extensions[extension] || this.extensions[".js"];
|
||||
loader(module, filename);
|
||||
return module.exports;
|
||||
}
|
||||
findLongestRegisteredExtension(filename) {
|
||||
const name = basename(filename);
|
||||
let currentExtension;
|
||||
let index;
|
||||
let startIndex = 0;
|
||||
// eslint-disable-next-line no-cond-assign
|
||||
while ((index = name.indexOf(".", startIndex)) !== -1) {
|
||||
startIndex = index + 1;
|
||||
if (index === 0) continue;
|
||||
currentExtension = name.slice(index);
|
||||
if (this.extensions[currentExtension]) return currentExtension;
|
||||
}
|
||||
return ".js";
|
||||
}
|
||||
getCoreSyntheticModule(identifier) {
|
||||
if (this.moduleCache.has(identifier)) return this.moduleCache.get(identifier);
|
||||
const exports = this.require(identifier);
|
||||
const keys = Object.keys(exports);
|
||||
const module = new SyntheticModule([...keys, "default"], () => {
|
||||
for (const key of keys) module.setExport(key, exports[key]);
|
||||
module.setExport("default", exports);
|
||||
}, {
|
||||
context: this.context,
|
||||
identifier
|
||||
});
|
||||
this.moduleCache.set(identifier, module);
|
||||
return module;
|
||||
}
|
||||
getCjsSyntheticModule(path, identifier) {
|
||||
if (this.moduleCache.has(identifier)) return this.moduleCache.get(identifier);
|
||||
const exports = this.require(path);
|
||||
// TODO: technically module should be parsed to find static exports, implement for strict mode in #2854
|
||||
const { keys, moduleExports, defaultExport } = interopCommonJsModule(this.interopDefault, exports);
|
||||
const module = new SyntheticModule([...keys, "default"], function() {
|
||||
for (const key of keys) this.setExport(key, moduleExports[key]);
|
||||
this.setExport("default", defaultExport);
|
||||
}, {
|
||||
context: this.context,
|
||||
identifier
|
||||
});
|
||||
this.moduleCache.set(identifier, module);
|
||||
return module;
|
||||
}
|
||||
// TODO: use this in strict mode, when available in #2854
|
||||
// private _getNamedCjsExports(path: string): Set<string> {
|
||||
// const cachedNamedExports = this.cjsNamedExportsMap.get(path)
|
||||
// if (cachedNamedExports) {
|
||||
// return cachedNamedExports
|
||||
// }
|
||||
// if (extname(path) === '.node') {
|
||||
// const moduleExports = this.require(path)
|
||||
// const namedExports = new Set(Object.keys(moduleExports))
|
||||
// this.cjsNamedExportsMap.set(path, namedExports)
|
||||
// return namedExports
|
||||
// }
|
||||
// const code = this.fs.readFile(path)
|
||||
// const { exports, reexports } = parseCjs(code, path)
|
||||
// const namedExports = new Set(exports)
|
||||
// this.cjsNamedExportsMap.set(path, namedExports)
|
||||
// for (const reexport of reexports) {
|
||||
// if (isNodeBuiltin(reexport)) {
|
||||
// const exports = this.require(reexport)
|
||||
// if (exports !== null && typeof exports === 'object') {
|
||||
// for (const e of Object.keys(exports)) {
|
||||
// namedExports.add(e)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// const require = this.createRequire(path)
|
||||
// const resolved = require.resolve(reexport)
|
||||
// const exports = this._getNamedCjsExports(resolved)
|
||||
// for (const e of exports) {
|
||||
// namedExports.add(e)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return namedExports
|
||||
// }
|
||||
require(identifier) {
|
||||
const ext = extname(identifier);
|
||||
if (ext === ".node" || isNodeBuiltin(identifier)) return this.requireCoreModule(identifier);
|
||||
const module = new this.Module(identifier);
|
||||
return this.loadCommonJSModule(module, identifier);
|
||||
}
|
||||
requireCoreModule(identifier) {
|
||||
const normalized = identifier.replace(/^node:/, "");
|
||||
if (this.builtinCache[normalized]) return this.builtinCache[normalized].exports;
|
||||
const moduleExports = _require(identifier);
|
||||
if (identifier === "node:module" || identifier === "module") {
|
||||
const module = new this.Module("/module.js");
|
||||
module.exports = this.Module;
|
||||
this.builtinCache[normalized] = module;
|
||||
return module.exports;
|
||||
}
|
||||
this.builtinCache[normalized] = _require.cache[normalized];
|
||||
// TODO: should we wrap module to rethrow context errors?
|
||||
return moduleExports;
|
||||
}
|
||||
}
|
||||
|
||||
const dataURIRegex = /^data:(?<mime>text\/javascript|application\/json|application\/wasm)(?:;(?<encoding>charset=utf-8|base64))?,(?<code>.*)$/;
|
||||
class EsmExecutor {
|
||||
moduleCache = /* @__PURE__ */ new Map();
|
||||
esmLinkMap = /* @__PURE__ */ new WeakMap();
|
||||
context;
|
||||
#httpIp = IPnumber("127.0.0.0");
|
||||
constructor(executor, options) {
|
||||
this.executor = executor;
|
||||
this.context = options.context;
|
||||
}
|
||||
async evaluateModule(m) {
|
||||
if (m.status === "unlinked") this.esmLinkMap.set(m, m.link((identifier, referencer) => this.executor.resolveModule(identifier, referencer.identifier)));
|
||||
await this.esmLinkMap.get(m);
|
||||
if (m.status === "linked") await m.evaluate();
|
||||
return m;
|
||||
}
|
||||
async createEsModule(fileURL, getCode) {
|
||||
const cached = this.moduleCache.get(fileURL);
|
||||
if (cached) return cached;
|
||||
const promise = this.loadEsModule(fileURL, getCode);
|
||||
this.moduleCache.set(fileURL, promise);
|
||||
return promise;
|
||||
}
|
||||
async loadEsModule(fileURL, getCode) {
|
||||
const code = await getCode();
|
||||
// TODO: should not be allowed in strict mode, implement in #2854
|
||||
if (fileURL.endsWith(".json")) {
|
||||
const m = new SyntheticModule(["default"], function() {
|
||||
const result = JSON.parse(code);
|
||||
this.setExport("default", result);
|
||||
});
|
||||
this.moduleCache.set(fileURL, m);
|
||||
return m;
|
||||
}
|
||||
const m = new SourceTextModule(code, {
|
||||
identifier: fileURL,
|
||||
context: this.context,
|
||||
importModuleDynamically: this.executor.importModuleDynamically,
|
||||
initializeImportMeta: (meta, mod) => {
|
||||
meta.url = mod.identifier;
|
||||
if (mod.identifier.startsWith("file:")) {
|
||||
const filename = fileURLToPath(mod.identifier);
|
||||
meta.filename = filename;
|
||||
meta.dirname = dirname$1(filename);
|
||||
}
|
||||
meta.resolve = (specifier, importer) => {
|
||||
return this.executor.resolve(specifier, importer != null ? importer.toString() : mod.identifier);
|
||||
};
|
||||
}
|
||||
});
|
||||
this.moduleCache.set(fileURL, m);
|
||||
return m;
|
||||
}
|
||||
async createWebAssemblyModule(fileUrl, getCode) {
|
||||
const cached = this.moduleCache.get(fileUrl);
|
||||
if (cached) return cached;
|
||||
const m = this.loadWebAssemblyModule(getCode(), fileUrl);
|
||||
this.moduleCache.set(fileUrl, m);
|
||||
return m;
|
||||
}
|
||||
async createNetworkModule(fileUrl) {
|
||||
// https://nodejs.org/api/esm.html#https-and-http-imports
|
||||
if (fileUrl.startsWith("http:")) {
|
||||
const url = new URL(fileUrl);
|
||||
if (url.hostname !== "localhost" && url.hostname !== "::1" && (IPnumber(url.hostname) & IPmask(8)) !== this.#httpIp) throw new Error(
|
||||
// we don't know the importer, so it's undefined (the same happens in --pool=threads)
|
||||
`import of '${fileUrl}' by undefined is not supported: http can only be used to load local resources (use https instead).`
|
||||
);
|
||||
}
|
||||
return this.createEsModule(fileUrl, () => fetch(fileUrl).then((r) => r.text()));
|
||||
}
|
||||
async loadWebAssemblyModule(source, identifier) {
|
||||
const cached = this.moduleCache.get(identifier);
|
||||
if (cached) return cached;
|
||||
const wasmModule = await WebAssembly.compile(source);
|
||||
const exports = WebAssembly.Module.exports(wasmModule);
|
||||
const imports = WebAssembly.Module.imports(wasmModule);
|
||||
const moduleLookup = {};
|
||||
for (const { module } of imports) if (moduleLookup[module] === void 0) moduleLookup[module] = await this.executor.resolveModule(module, identifier);
|
||||
const evaluateModule = (module) => this.evaluateModule(module);
|
||||
const syntheticModule = new SyntheticModule(exports.map(({ name }) => name), async function() {
|
||||
const importsObject = {};
|
||||
for (const { module, name } of imports) {
|
||||
if (!importsObject[module]) importsObject[module] = {};
|
||||
await evaluateModule(moduleLookup[module]);
|
||||
importsObject[module][name] = moduleLookup[module].namespace[name];
|
||||
}
|
||||
const wasmInstance = new WebAssembly.Instance(wasmModule, importsObject);
|
||||
for (const { name } of exports) this.setExport(name, wasmInstance.exports[name]);
|
||||
}, {
|
||||
context: this.context,
|
||||
identifier
|
||||
});
|
||||
return syntheticModule;
|
||||
}
|
||||
cacheModule(identifier, module) {
|
||||
this.moduleCache.set(identifier, module);
|
||||
}
|
||||
resolveCachedModule(identifier) {
|
||||
return this.moduleCache.get(identifier);
|
||||
}
|
||||
async createDataModule(identifier) {
|
||||
const cached = this.moduleCache.get(identifier);
|
||||
if (cached) return cached;
|
||||
const match = identifier.match(dataURIRegex);
|
||||
if (!match || !match.groups) throw new Error("Invalid data URI");
|
||||
const mime = match.groups.mime;
|
||||
const encoding = match.groups.encoding;
|
||||
if (mime === "application/wasm") {
|
||||
if (!encoding) throw new Error("Missing data URI encoding");
|
||||
if (encoding !== "base64") throw new Error(`Invalid data URI encoding: ${encoding}`);
|
||||
const module = this.loadWebAssemblyModule(Buffer.from(match.groups.code, "base64"), identifier);
|
||||
this.moduleCache.set(identifier, module);
|
||||
return module;
|
||||
}
|
||||
let code = match.groups.code;
|
||||
if (!encoding || encoding === "charset=utf-8") code = decodeURIComponent(code);
|
||||
else if (encoding === "base64") code = Buffer.from(code, "base64").toString();
|
||||
else throw new Error(`Invalid data URI encoding: ${encoding}`);
|
||||
if (mime === "application/json") {
|
||||
const module = new SyntheticModule(["default"], function() {
|
||||
const obj = JSON.parse(code);
|
||||
this.setExport("default", obj);
|
||||
}, {
|
||||
context: this.context,
|
||||
identifier
|
||||
});
|
||||
this.moduleCache.set(identifier, module);
|
||||
return module;
|
||||
}
|
||||
return this.createEsModule(identifier, () => code);
|
||||
}
|
||||
}
|
||||
function IPnumber(address) {
|
||||
const ip = address.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
|
||||
if (ip) return (+ip[1] << 24) + (+ip[2] << 16) + (+ip[3] << 8) + +ip[4];
|
||||
throw new Error(`Expected IP address, received ${address}`);
|
||||
}
|
||||
function IPmask(maskSize) {
|
||||
return -1 << 32 - maskSize;
|
||||
}
|
||||
|
||||
const CLIENT_ID = "/@vite/client";
|
||||
const CLIENT_FILE = pathToFileURL(CLIENT_ID).href;
|
||||
class ViteExecutor {
|
||||
esm;
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
this.esm = options.esmExecutor;
|
||||
}
|
||||
resolve = (identifier, parent) => {
|
||||
if (identifier === CLIENT_ID) {
|
||||
if (this.workerState.environment.transformMode === "web") return identifier;
|
||||
const packageName = this.getPackageName(parent);
|
||||
throw new Error(`[vitest] Vitest cannot handle ${CLIENT_ID} imported in ${parent} when running in SSR environment. Add "${packageName}" to "ssr.noExternal" if you are using Vite SSR, or to "server.deps.inline" if you are using Vite Node.`);
|
||||
}
|
||||
};
|
||||
get workerState() {
|
||||
return this.options.context.__vitest_worker__;
|
||||
}
|
||||
getPackageName(modulePath) {
|
||||
const path = normalize(modulePath);
|
||||
let name = path.split("/node_modules/").pop() || "";
|
||||
if (name?.startsWith("@")) name = name.split("/").slice(0, 2).join("/");
|
||||
else name = name.split("/")[0];
|
||||
return name;
|
||||
}
|
||||
async createViteModule(fileUrl) {
|
||||
if (fileUrl === CLIENT_FILE) return this.createViteClientModule();
|
||||
const cached = this.esm.resolveCachedModule(fileUrl);
|
||||
if (cached) return cached;
|
||||
return this.esm.createEsModule(fileUrl, async () => {
|
||||
try {
|
||||
const result = await this.options.transform(fileUrl, "web");
|
||||
if (result.code) return result.code;
|
||||
} catch (cause) {
|
||||
// rethrow vite error if it cannot load the module because it's not resolved
|
||||
if (typeof cause === "object" && cause.code === "ERR_LOAD_URL" || typeof cause?.message === "string" && cause.message.includes("Failed to load url")) {
|
||||
const error = new Error(`Cannot find module '${fileUrl}'`, { cause });
|
||||
error.code = "ERR_MODULE_NOT_FOUND";
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
throw new Error(`[vitest] Failed to transform ${fileUrl}. Does the file exist?`);
|
||||
});
|
||||
}
|
||||
createViteClientModule() {
|
||||
const identifier = CLIENT_ID;
|
||||
const cached = this.esm.resolveCachedModule(identifier);
|
||||
if (cached) return cached;
|
||||
const stub = this.options.viteClientModule;
|
||||
const moduleKeys = Object.keys(stub);
|
||||
const module = new SyntheticModule(moduleKeys, function() {
|
||||
moduleKeys.forEach((key) => {
|
||||
this.setExport(key, stub[key]);
|
||||
});
|
||||
}, {
|
||||
context: this.options.context,
|
||||
identifier
|
||||
});
|
||||
this.esm.cacheModule(identifier, module);
|
||||
return module;
|
||||
}
|
||||
canResolve = (fileUrl) => {
|
||||
const transformMode = this.workerState.environment.transformMode;
|
||||
if (transformMode !== "web") return false;
|
||||
if (fileUrl === CLIENT_FILE) return true;
|
||||
const config = this.workerState.config.deps?.web || {};
|
||||
const [modulePath] = fileUrl.split("?");
|
||||
if (config.transformCss && CSS_LANGS_RE.test(modulePath)) return true;
|
||||
if (config.transformAssets && KNOWN_ASSET_RE.test(modulePath)) return true;
|
||||
if (toArray(config.transformGlobPattern).some((pattern) => pattern.test(modulePath))) return true;
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
const { existsSync, statSync } = fs;
|
||||
// always defined when we use vm pool
|
||||
const nativeResolve = import.meta.resolve;
|
||||
// TODO: improve Node.js strict mode support in #2854
|
||||
class ExternalModulesExecutor {
|
||||
cjs;
|
||||
esm;
|
||||
vite;
|
||||
context;
|
||||
fs;
|
||||
resolvers = [];
|
||||
#networkSupported = null;
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
this.context = options.context;
|
||||
this.fs = options.fileMap;
|
||||
this.esm = new EsmExecutor(this, { context: this.context });
|
||||
this.cjs = new CommonjsExecutor({
|
||||
context: this.context,
|
||||
importModuleDynamically: this.importModuleDynamically,
|
||||
fileMap: options.fileMap,
|
||||
interopDefault: options.interopDefault
|
||||
});
|
||||
this.vite = new ViteExecutor({
|
||||
esmExecutor: this.esm,
|
||||
context: this.context,
|
||||
transform: options.transform,
|
||||
viteClientModule: options.viteClientModule
|
||||
});
|
||||
this.resolvers = [this.vite.resolve];
|
||||
}
|
||||
async import(identifier) {
|
||||
const module = await this.createModule(identifier);
|
||||
await this.esm.evaluateModule(module);
|
||||
return module.namespace;
|
||||
}
|
||||
require(identifier) {
|
||||
return this.cjs.require(identifier);
|
||||
}
|
||||
createRequire(identifier) {
|
||||
return this.cjs.createRequire(identifier);
|
||||
}
|
||||
// dynamic import can be used in both ESM and CJS, so we have it in the executor
|
||||
importModuleDynamically = async (specifier, referencer) => {
|
||||
const module = await this.resolveModule(specifier, referencer.identifier);
|
||||
return await this.esm.evaluateModule(module);
|
||||
};
|
||||
resolveModule = async (specifier, referencer) => {
|
||||
let identifier = this.resolve(specifier, referencer);
|
||||
if (identifier instanceof Promise) identifier = await identifier;
|
||||
return await this.createModule(identifier);
|
||||
};
|
||||
resolve(specifier, parent) {
|
||||
for (const resolver of this.resolvers) {
|
||||
const id = resolver(specifier, parent);
|
||||
if (id) return id;
|
||||
}
|
||||
// import.meta.resolve can be asynchronous in older +18 Node versions
|
||||
return nativeResolve(specifier, parent);
|
||||
}
|
||||
findNearestPackageData(basedir) {
|
||||
const originalBasedir = basedir;
|
||||
const packageCache = this.options.packageCache;
|
||||
while (basedir) {
|
||||
const cached = getCachedData(packageCache, basedir, originalBasedir);
|
||||
if (cached) return cached;
|
||||
const pkgPath = join(basedir, "package.json");
|
||||
try {
|
||||
if (statSync(pkgPath, { throwIfNoEntry: false })?.isFile()) {
|
||||
const pkgData = JSON.parse(this.fs.readFile(pkgPath));
|
||||
if (packageCache) setCacheData(packageCache, pkgData, basedir, originalBasedir);
|
||||
return pkgData;
|
||||
}
|
||||
} catch {}
|
||||
const nextBasedir = dirname$1(basedir);
|
||||
if (nextBasedir === basedir) break;
|
||||
basedir = nextBasedir;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
getModuleInformation(identifier) {
|
||||
if (identifier.startsWith("data:")) return {
|
||||
type: "data",
|
||||
url: identifier,
|
||||
path: identifier
|
||||
};
|
||||
const extension = extname(identifier);
|
||||
if (extension === ".node" || isNodeBuiltin(identifier)) return {
|
||||
type: "builtin",
|
||||
url: identifier,
|
||||
path: identifier
|
||||
};
|
||||
if (this.isNetworkSupported && (identifier.startsWith("http:") || identifier.startsWith("https:"))) return {
|
||||
type: "network",
|
||||
url: identifier,
|
||||
path: identifier
|
||||
};
|
||||
const isFileUrl = identifier.startsWith("file://");
|
||||
const pathUrl = isFileUrl ? fileURLToPath(identifier.split("?")[0]) : identifier;
|
||||
const fileUrl = isFileUrl ? identifier : pathToFileURL(pathUrl).toString();
|
||||
let type;
|
||||
if (this.vite.canResolve(fileUrl)) type = "vite";
|
||||
else if (extension === ".mjs") type = "module";
|
||||
else if (extension === ".cjs") type = "commonjs";
|
||||
else if (extension === ".wasm")
|
||||
// still experimental on NodeJS --experimental-wasm-modules
|
||||
// cf. ESM_FILE_FORMAT(url) in https://nodejs.org/docs/latest-v20.x/api/esm.html#resolution-algorithm
|
||||
type = "wasm";
|
||||
else {
|
||||
const pkgData = this.findNearestPackageData(normalize(pathUrl));
|
||||
type = pkgData.type === "module" ? "module" : "commonjs";
|
||||
}
|
||||
return {
|
||||
type,
|
||||
path: pathUrl,
|
||||
url: fileUrl
|
||||
};
|
||||
}
|
||||
createModule(identifier) {
|
||||
const { type, url, path } = this.getModuleInformation(identifier);
|
||||
// create ERR_MODULE_NOT_FOUND on our own since latest NodeJS's import.meta.resolve doesn't throw on non-existing namespace or path
|
||||
// https://github.com/nodejs/node/pull/49038
|
||||
if ((type === "module" || type === "commonjs" || type === "wasm") && !existsSync(path)) {
|
||||
const error = new Error(`Cannot find ${isBareImport(path) ? "package" : "module"} '${path}'`);
|
||||
error.code = "ERR_MODULE_NOT_FOUND";
|
||||
throw error;
|
||||
}
|
||||
switch (type) {
|
||||
case "data": return this.esm.createDataModule(identifier);
|
||||
case "builtin": return this.cjs.getCoreSyntheticModule(identifier);
|
||||
case "vite": return this.vite.createViteModule(url);
|
||||
case "wasm": return this.esm.createWebAssemblyModule(url, () => this.fs.readBuffer(path));
|
||||
case "module": return this.esm.createEsModule(url, () => this.fs.readFileAsync(path));
|
||||
case "commonjs": return this.cjs.getCjsSyntheticModule(path, identifier);
|
||||
case "network": return this.esm.createNetworkModule(url);
|
||||
default: {
|
||||
const _deadend = type;
|
||||
return _deadend;
|
||||
}
|
||||
}
|
||||
}
|
||||
get isNetworkSupported() {
|
||||
if (this.#networkSupported == null) if (process.execArgv.includes("--experimental-network-imports")) this.#networkSupported = true;
|
||||
else if (process.env.NODE_OPTIONS?.includes("--experimental-network-imports")) this.#networkSupported = true;
|
||||
else this.#networkSupported = false;
|
||||
return this.#networkSupported;
|
||||
}
|
||||
}
|
||||
|
||||
const { promises, readFileSync } = fs;
|
||||
class FileMap {
|
||||
fsCache = /* @__PURE__ */ new Map();
|
||||
fsBufferCache = /* @__PURE__ */ new Map();
|
||||
async readFileAsync(path) {
|
||||
const cached = this.fsCache.get(path);
|
||||
if (cached != null) return cached;
|
||||
const source = await promises.readFile(path, "utf-8");
|
||||
this.fsCache.set(path, source);
|
||||
return source;
|
||||
}
|
||||
readFile(path) {
|
||||
const cached = this.fsCache.get(path);
|
||||
if (cached != null) return cached;
|
||||
const source = readFileSync(path, "utf-8");
|
||||
this.fsCache.set(path, source);
|
||||
return source;
|
||||
}
|
||||
readBuffer(path) {
|
||||
const cached = this.fsBufferCache.get(path);
|
||||
if (cached != null) return cached;
|
||||
const buffer = readFileSync(path);
|
||||
this.fsBufferCache.set(path, buffer);
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
||||
const entryFile = pathToFileURL(resolve(distDir, "workers/runVmTests.js")).href;
|
||||
const fileMap = new FileMap();
|
||||
const packageCache = /* @__PURE__ */ new Map();
|
||||
async function runVmTests(method, state) {
|
||||
const { environment, ctx, rpc } = state;
|
||||
if (!environment.setupVM) {
|
||||
const envName = ctx.environment.name;
|
||||
const packageId = envName[0] === "." ? envName : `vitest-environment-${envName}`;
|
||||
throw new TypeError(`Environment "${ctx.environment.name}" is not a valid environment. Path "${packageId}" doesn't support vm environment because it doesn't provide "setupVM" method.`);
|
||||
}
|
||||
const vm = await environment.setupVM(ctx.environment.options || ctx.config.environmentOptions || {});
|
||||
state.durations.environment = performance.now() - state.durations.environment;
|
||||
process.env.VITEST_VM_POOL = "1";
|
||||
if (!vm.getVmContext) throw new TypeError(`Environment ${environment.name} doesn't provide "getVmContext" method. It should return a context created by "vm.createContext" method.`);
|
||||
const context = vm.getVmContext();
|
||||
if (!isContext(context)) throw new TypeError(`Environment ${environment.name} doesn't provide a valid context. It should be created by "vm.createContext" method.`);
|
||||
provideWorkerState(context, state);
|
||||
// this is unfortunately needed for our own dependencies
|
||||
// we need to find a way to not rely on this by default
|
||||
// because browser doesn't provide these globals
|
||||
context.process = process;
|
||||
context.global = context;
|
||||
context.console = state.config.disableConsoleIntercept ? console : createCustomConsole(state);
|
||||
// TODO: don't hardcode setImmediate in fake timers defaults
|
||||
context.setImmediate = setImmediate;
|
||||
context.clearImmediate = clearImmediate;
|
||||
const stubs = getDefaultRequestStubs(context);
|
||||
const externalModulesExecutor = new ExternalModulesExecutor({
|
||||
context,
|
||||
fileMap,
|
||||
packageCache,
|
||||
transform: rpc.transform,
|
||||
viteClientModule: stubs["/@vite/client"]
|
||||
});
|
||||
const executor = await startVitestExecutor({
|
||||
context,
|
||||
moduleCache: state.moduleCache,
|
||||
state,
|
||||
externalModulesExecutor,
|
||||
requestStubs: stubs
|
||||
});
|
||||
context.__vitest_mocker__ = executor.mocker;
|
||||
const { run } = await executor.importExternalModule(entryFile);
|
||||
const fileSpecs = ctx.files.map((f) => typeof f === "string" ? {
|
||||
filepath: f,
|
||||
testLocations: void 0
|
||||
} : f);
|
||||
try {
|
||||
await run(method, fileSpecs, ctx.config, executor);
|
||||
} finally {
|
||||
await vm.teardown?.();
|
||||
state.environmentTeardownRun = true;
|
||||
}
|
||||
}
|
||||
|
||||
export { runVmTests as r };
|
||||
176
node_modules/vitest/dist/chunks/worker.d.CUgIPz9V.d.ts
generated
vendored
Normal file
176
node_modules/vitest/dist/chunks/worker.d.CUgIPz9V.d.ts
generated
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
import { File, TestAnnotation, TaskResultPack, TaskEventPack, CancelReason, FileSpecification, Task } from '@vitest/runner';
|
||||
import { ViteNodeResolveId, ModuleCacheMap, ModuleExecutionInfo } from 'vite-node';
|
||||
import { a as SerializedConfig } from './config.d.BKdhh7Zx.js';
|
||||
import { T as TransformMode, U as UserConsoleLog, A as AfterSuiteRunMeta, E as Environment } from './environment.d.cL3nLXbE.js';
|
||||
import { SnapshotResult } from '@vitest/snapshot';
|
||||
|
||||
type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
|
||||
type ReturnType<T> = T extends (...args: any) => infer R ? R : never;
|
||||
type PromisifyFn<T> = ReturnType<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType<T>>>;
|
||||
type BirpcResolver = (name: string, resolved: (...args: unknown[]) => unknown) => ((...args: unknown[]) => unknown) | undefined;
|
||||
interface ChannelOptions {
|
||||
/**
|
||||
* Function to post raw message
|
||||
*/
|
||||
post: (data: any, ...extras: any[]) => any | Promise<any>;
|
||||
/**
|
||||
* Listener to receive raw message
|
||||
*/
|
||||
on: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
|
||||
/**
|
||||
* Clear the listener when `$close` is called
|
||||
*/
|
||||
off?: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
|
||||
/**
|
||||
* Custom function to serialize data
|
||||
*
|
||||
* by default it passes the data as-is
|
||||
*/
|
||||
serialize?: (data: any) => any;
|
||||
/**
|
||||
* Custom function to deserialize data
|
||||
*
|
||||
* by default it passes the data as-is
|
||||
*/
|
||||
deserialize?: (data: any) => any;
|
||||
/**
|
||||
* Call the methods with the RPC context or the original functions object
|
||||
*/
|
||||
bind?: 'rpc' | 'functions';
|
||||
}
|
||||
interface EventOptions<Remote> {
|
||||
/**
|
||||
* Names of remote functions that do not need response.
|
||||
*/
|
||||
eventNames?: (keyof Remote)[];
|
||||
/**
|
||||
* Maximum timeout for waiting for response, in milliseconds.
|
||||
*
|
||||
* @default 60_000
|
||||
*/
|
||||
timeout?: number;
|
||||
/**
|
||||
* Custom resolver to resolve function to be called
|
||||
*
|
||||
* For advanced use cases only
|
||||
*/
|
||||
resolver?: BirpcResolver;
|
||||
/**
|
||||
* Custom error handler
|
||||
*
|
||||
* @deprecated use `onFunctionError` and `onGeneralError` instead
|
||||
*/
|
||||
onError?: (error: Error, functionName: string, args: any[]) => boolean | void;
|
||||
/**
|
||||
* Custom error handler for errors occurred in local functions being called
|
||||
*
|
||||
* @returns `true` to prevent the error from being thrown
|
||||
*/
|
||||
onFunctionError?: (error: Error, functionName: string, args: any[]) => boolean | void;
|
||||
/**
|
||||
* Custom error handler for errors occurred during serialization or messsaging
|
||||
*
|
||||
* @returns `true` to prevent the error from being thrown
|
||||
*/
|
||||
onGeneralError?: (error: Error, functionName?: string, args?: any[]) => boolean | void;
|
||||
/**
|
||||
* Custom error handler for timeouts
|
||||
*
|
||||
* @returns `true` to prevent the error from being thrown
|
||||
*/
|
||||
onTimeoutError?: (functionName: string, args: any[]) => boolean | void;
|
||||
}
|
||||
type BirpcOptions<Remote> = EventOptions<Remote> & ChannelOptions;
|
||||
type BirpcFn<T> = PromisifyFn<T> & {
|
||||
/**
|
||||
* Send event without asking for response
|
||||
*/
|
||||
asEvent: (...args: ArgumentsType<T>) => void;
|
||||
};
|
||||
type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
|
||||
[K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
|
||||
} & {
|
||||
$functions: LocalFunctions;
|
||||
$close: (error?: Error) => void;
|
||||
$closed: boolean;
|
||||
};
|
||||
|
||||
interface RuntimeRPC {
|
||||
fetch: (id: string, transformMode: TransformMode) => Promise<{
|
||||
externalize?: string
|
||||
id?: string
|
||||
}>;
|
||||
transform: (id: string, transformMode: TransformMode) => Promise<{
|
||||
code?: string
|
||||
}>;
|
||||
resolveId: (id: string, importer: string | undefined, transformMode: TransformMode) => Promise<{
|
||||
external?: boolean | "absolute" | "relative"
|
||||
id: string
|
||||
/** @deprecated */
|
||||
meta?: Record<string, any> | null
|
||||
/** @deprecated */
|
||||
moduleSideEffects?: boolean | "no-treeshake" | null
|
||||
/** @deprecated */
|
||||
syntheticNamedExports?: boolean | string | null
|
||||
} | null>;
|
||||
/**
|
||||
* @deprecated unused
|
||||
*/
|
||||
getSourceMap: (id: string, force?: boolean) => Promise<any>;
|
||||
onUserConsoleLog: (log: UserConsoleLog) => void;
|
||||
onUnhandledError: (err: unknown, type: string) => void;
|
||||
onQueued: (file: File) => void;
|
||||
onCollected: (files: File[]) => Promise<void>;
|
||||
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
|
||||
onTaskAnnotate: (testId: string, annotation: TestAnnotation) => Promise<TestAnnotation>;
|
||||
onTaskUpdate: (pack: TaskResultPack[], events: TaskEventPack[]) => Promise<void>;
|
||||
onCancel: (reason: CancelReason) => void;
|
||||
getCountOfFailedTests: () => number;
|
||||
snapshotSaved: (snapshot: SnapshotResult) => void;
|
||||
resolveSnapshotPath: (testPath: string) => string;
|
||||
}
|
||||
interface RunnerRPC {
|
||||
onCancel: (reason: CancelReason) => void;
|
||||
}
|
||||
|
||||
/** @deprecated unused */
|
||||
type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
|
||||
type WorkerRPC = BirpcReturn<RuntimeRPC, RunnerRPC>;
|
||||
interface ContextTestEnvironment {
|
||||
name: string;
|
||||
transformMode?: TransformMode;
|
||||
options: Record<string, any> | null;
|
||||
}
|
||||
type TestExecutionMethod = "run" | "collect";
|
||||
interface ContextRPC {
|
||||
pool: string;
|
||||
worker: string;
|
||||
workerId: number;
|
||||
config: SerializedConfig;
|
||||
projectName: string;
|
||||
files: string[] | FileSpecification[];
|
||||
environment: ContextTestEnvironment;
|
||||
providedContext: Record<string, any>;
|
||||
invalidates?: string[];
|
||||
}
|
||||
interface WorkerGlobalState {
|
||||
ctx: ContextRPC;
|
||||
config: SerializedConfig;
|
||||
rpc: WorkerRPC;
|
||||
current?: Task;
|
||||
filepath?: string;
|
||||
environment: Environment;
|
||||
environmentTeardownRun?: boolean;
|
||||
onCancel: Promise<CancelReason>;
|
||||
moduleCache: ModuleCacheMap;
|
||||
moduleExecutionInfo?: ModuleExecutionInfo;
|
||||
onCleanup: (listener: () => unknown) => void;
|
||||
providedContext: Record<string, any>;
|
||||
durations: {
|
||||
environment: number
|
||||
prepare: number
|
||||
};
|
||||
onFilterStackTrace?: (trace: string) => string;
|
||||
}
|
||||
|
||||
export type { BirpcOptions as B, ContextRPC as C, RuntimeRPC as R, TestExecutionMethod as T, WorkerGlobalState as W, BirpcReturn as a, WorkerRPC as b, RunnerRPC as c, ContextTestEnvironment as d, ResolveIdFunction as e };
|
||||
8
node_modules/vitest/dist/chunks/worker.d.uzWsCv9X.d.ts
generated
vendored
Normal file
8
node_modules/vitest/dist/chunks/worker.d.uzWsCv9X.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { MessagePort } from 'node:worker_threads';
|
||||
import { C as ContextRPC } from './worker.d.CUgIPz9V.js';
|
||||
|
||||
interface WorkerContext extends ContextRPC {
|
||||
port: MessagePort;
|
||||
}
|
||||
|
||||
export type { WorkerContext as W };
|
||||
27
node_modules/vitest/dist/cli.js
generated
vendored
Normal file
27
node_modules/vitest/dist/cli.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { c as createCLI } from './chunks/cac.0BJqEUeA.js';
|
||||
import '@vitest/utils';
|
||||
import 'events';
|
||||
import 'pathe';
|
||||
import 'tinyrainbow';
|
||||
import './chunks/constants.DnKduX2e.js';
|
||||
import './chunks/index.VByaPkjc.js';
|
||||
import 'node:perf_hooks';
|
||||
import '@vitest/runner/utils';
|
||||
import '@vitest/utils/source-map';
|
||||
import './chunks/env.D4Lgay0q.js';
|
||||
import 'std-env';
|
||||
import './chunks/typechecker.DRKU1-1g.js';
|
||||
import 'node:os';
|
||||
import 'tinyexec';
|
||||
import './path.js';
|
||||
import 'node:path';
|
||||
import 'node:url';
|
||||
import 'vite';
|
||||
import 'node:util';
|
||||
import 'node:fs';
|
||||
import 'node:fs/promises';
|
||||
import 'node:console';
|
||||
import 'node:stream';
|
||||
import 'node:module';
|
||||
|
||||
createCLI().parse();
|
||||
148
node_modules/vitest/dist/config.cjs
generated
vendored
Normal file
148
node_modules/vitest/dist/config.cjs
generated
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
'use strict';
|
||||
|
||||
var os = require('node:os');
|
||||
var stdEnv = require('std-env');
|
||||
var vite = require('vite');
|
||||
|
||||
// if changed, update also jsdocs and docs
|
||||
const defaultBrowserPort = 63315;
|
||||
const extraInlineDeps = [
|
||||
/^(?!.*node_modules).*\.mjs$/,
|
||||
/^(?!.*node_modules).*\.cjs\.js$/,
|
||||
/vite\w*\/dist\/client\/env.mjs/
|
||||
];
|
||||
|
||||
const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions?.deno && !globalThis.window;
|
||||
const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== void 0;
|
||||
(isNode || isDeno) && process.platform === "win32";
|
||||
(isNode || isDeno) && process.stdout?.isTTY && !stdEnv.isCI;
|
||||
|
||||
const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
|
||||
const defaultExclude = [
|
||||
"**/node_modules/**",
|
||||
"**/dist/**",
|
||||
"**/cypress/**",
|
||||
"**/.{idea,git,cache,output,temp}/**",
|
||||
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*"
|
||||
];
|
||||
const defaultCoverageExcludes = [
|
||||
"coverage/**",
|
||||
"dist/**",
|
||||
"**/node_modules/**",
|
||||
"**/[.]**",
|
||||
"packages/*/test?(s)/**",
|
||||
"**/*.d.ts",
|
||||
"**/virtual:*",
|
||||
"**/__x00__*",
|
||||
"**/\0*",
|
||||
"cypress/**",
|
||||
"test?(s)/**",
|
||||
"test?(-*).?(c|m)[jt]s?(x)",
|
||||
"**/*{.,-}{test,spec,bench,benchmark}?(-d).?(c|m)[jt]s?(x)",
|
||||
"**/__tests__/**",
|
||||
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*",
|
||||
"**/vitest.{workspace,projects}.[jt]s?(on)",
|
||||
"**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}"
|
||||
];
|
||||
// These are the generic defaults for coverage. Providers may also set some provider specific defaults.
|
||||
const coverageConfigDefaults = {
|
||||
provider: "v8",
|
||||
enabled: false,
|
||||
all: true,
|
||||
clean: true,
|
||||
cleanOnRerun: true,
|
||||
reportsDirectory: "./coverage",
|
||||
exclude: defaultCoverageExcludes,
|
||||
reportOnFailure: false,
|
||||
reporter: [
|
||||
["text", {}],
|
||||
["html", {}],
|
||||
["clover", {}],
|
||||
["json", {}]
|
||||
],
|
||||
extension: [
|
||||
".js",
|
||||
".cjs",
|
||||
".mjs",
|
||||
".ts",
|
||||
".mts",
|
||||
".tsx",
|
||||
".jsx",
|
||||
".vue",
|
||||
".svelte",
|
||||
".marko",
|
||||
".astro"
|
||||
],
|
||||
allowExternal: false,
|
||||
excludeAfterRemap: false,
|
||||
ignoreEmptyLines: true,
|
||||
processingConcurrency: Math.min(20, os.availableParallelism?.() ?? os.cpus().length)
|
||||
};
|
||||
const fakeTimersDefaults = {
|
||||
loopLimit: 1e4,
|
||||
shouldClearNativeTimers: true
|
||||
};
|
||||
const configDefaults = Object.freeze({
|
||||
allowOnly: !stdEnv.isCI,
|
||||
isolate: true,
|
||||
watch: !stdEnv.isCI && process.stdin.isTTY,
|
||||
globals: false,
|
||||
environment: "node",
|
||||
pool: "forks",
|
||||
clearMocks: false,
|
||||
restoreMocks: false,
|
||||
mockReset: false,
|
||||
unstubGlobals: false,
|
||||
unstubEnvs: false,
|
||||
include: defaultInclude,
|
||||
exclude: defaultExclude,
|
||||
teardownTimeout: 1e4,
|
||||
forceRerunTriggers: ["**/package.json/**", "**/{vitest,vite}.config.*/**"],
|
||||
update: false,
|
||||
reporters: [],
|
||||
silent: false,
|
||||
hideSkippedTests: false,
|
||||
api: false,
|
||||
ui: false,
|
||||
uiBase: "/__vitest__/",
|
||||
open: !stdEnv.isCI,
|
||||
css: { include: [] },
|
||||
coverage: coverageConfigDefaults,
|
||||
fakeTimers: fakeTimersDefaults,
|
||||
maxConcurrency: 5,
|
||||
dangerouslyIgnoreUnhandledErrors: false,
|
||||
typecheck: {
|
||||
checker: "tsc",
|
||||
include: ["**/*.{test,spec}-d.?(c|m)[jt]s?(x)"],
|
||||
exclude: defaultExclude
|
||||
},
|
||||
slowTestThreshold: 300,
|
||||
disableConsoleIntercept: false
|
||||
});
|
||||
|
||||
function defineConfig(config) {
|
||||
return config;
|
||||
}
|
||||
function defineProject(config) {
|
||||
return config;
|
||||
}
|
||||
/**
|
||||
* @deprecated use the `projects` field in the root config instead
|
||||
*/
|
||||
function defineWorkspace(config) {
|
||||
return config;
|
||||
}
|
||||
|
||||
Object.defineProperty(exports, "mergeConfig", {
|
||||
enumerable: true,
|
||||
get: function () { return vite.mergeConfig; }
|
||||
});
|
||||
exports.configDefaults = configDefaults;
|
||||
exports.coverageConfigDefaults = coverageConfigDefaults;
|
||||
exports.defaultBrowserPort = defaultBrowserPort;
|
||||
exports.defaultExclude = defaultExclude;
|
||||
exports.defaultInclude = defaultInclude;
|
||||
exports.defineConfig = defineConfig;
|
||||
exports.defineProject = defineProject;
|
||||
exports.defineWorkspace = defineWorkspace;
|
||||
exports.extraInlineDeps = extraInlineDeps;
|
||||
100
node_modules/vitest/dist/config.d.ts
generated
vendored
Normal file
100
node_modules/vitest/dist/config.d.ts
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
import { UserConfig as UserConfig$1, ConfigEnv } from 'vite';
|
||||
export { ConfigEnv, Plugin, UserConfig as ViteUserConfig, mergeConfig } from 'vite';
|
||||
import { c as CoverageV8Options, R as ResolvedCoverageOptions, U as UserWorkspaceConfig, d as UserProjectConfigFn, e as UserProjectConfigExport, b as TestProjectConfiguration } from './chunks/reporters.d.BuRON0I0.js';
|
||||
export { f as TestProjectInlineConfiguration, g as WatcherTriggerPattern, W as WorkspaceProjectConfiguration } from './chunks/reporters.d.BuRON0I0.js';
|
||||
import './chunks/vite.d.BnOPPc46.js';
|
||||
import { F as FakeTimerInstallOpts } from './chunks/config.d.BKdhh7Zx.js';
|
||||
import '@vitest/runner';
|
||||
import './chunks/environment.d.cL3nLXbE.js';
|
||||
import 'vitest/optional-types.js';
|
||||
import '@vitest/utils';
|
||||
import 'node:stream';
|
||||
import 'node:console';
|
||||
import '@vitest/mocker';
|
||||
import '@vitest/utils/source-map';
|
||||
import './chunks/worker.d.CUgIPz9V.js';
|
||||
import 'vite-node';
|
||||
import '@vitest/snapshot';
|
||||
import '@vitest/pretty-format';
|
||||
import '@vitest/utils/diff';
|
||||
import 'chai';
|
||||
import './chunks/benchmark.d.BwvBVTda.js';
|
||||
import '@vitest/runner/utils';
|
||||
import 'tinybench';
|
||||
import './chunks/coverage.d.S9RMNXIe.js';
|
||||
import 'vite-node/client';
|
||||
import '@vitest/snapshot/manager';
|
||||
import 'node:fs';
|
||||
import '@vitest/snapshot/environment';
|
||||
|
||||
declare const defaultBrowserPort = 63315;
|
||||
declare const extraInlineDeps: RegExp[];
|
||||
|
||||
declare const defaultInclude: string[];
|
||||
declare const defaultExclude: string[];
|
||||
// These are the generic defaults for coverage. Providers may also set some provider specific defaults.
|
||||
declare const coverageConfigDefaults: ResolvedCoverageOptions;
|
||||
declare const configDefaults: Readonly<{
|
||||
allowOnly: boolean
|
||||
isolate: boolean
|
||||
watch: boolean
|
||||
globals: boolean
|
||||
environment: "node"
|
||||
pool: "forks"
|
||||
clearMocks: boolean
|
||||
restoreMocks: boolean
|
||||
mockReset: boolean
|
||||
unstubGlobals: boolean
|
||||
unstubEnvs: boolean
|
||||
include: string[]
|
||||
exclude: string[]
|
||||
teardownTimeout: number
|
||||
forceRerunTriggers: string[]
|
||||
update: boolean
|
||||
reporters: never[]
|
||||
silent: boolean
|
||||
hideSkippedTests: boolean
|
||||
api: boolean
|
||||
ui: boolean
|
||||
uiBase: string
|
||||
open: boolean
|
||||
css: {
|
||||
include: never[]
|
||||
}
|
||||
coverage: CoverageV8Options
|
||||
fakeTimers: FakeTimerInstallOpts
|
||||
maxConcurrency: number
|
||||
dangerouslyIgnoreUnhandledErrors: boolean
|
||||
typecheck: {
|
||||
checker: "tsc"
|
||||
include: string[]
|
||||
exclude: string[]
|
||||
}
|
||||
slowTestThreshold: number
|
||||
disableConsoleIntercept: boolean
|
||||
}>;
|
||||
|
||||
/**
|
||||
* @deprecated Use `ViteUserConfig` instead
|
||||
*/
|
||||
type UserConfig = UserConfig$1;
|
||||
|
||||
type UserConfigFnObject = (env: ConfigEnv) => UserConfig$1;
|
||||
type UserConfigFnPromise = (env: ConfigEnv) => Promise<UserConfig$1>;
|
||||
type UserConfigFn = (env: ConfigEnv) => UserConfig$1 | Promise<UserConfig$1>;
|
||||
type UserConfigExport = UserConfig$1 | Promise<UserConfig$1> | UserConfigFnObject | UserConfigFnPromise | UserConfigFn;
|
||||
declare function defineConfig(config: UserConfig$1): UserConfig$1;
|
||||
declare function defineConfig(config: Promise<UserConfig$1>): Promise<UserConfig$1>;
|
||||
declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
|
||||
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
||||
declare function defineProject(config: UserWorkspaceConfig): UserWorkspaceConfig;
|
||||
declare function defineProject(config: Promise<UserWorkspaceConfig>): Promise<UserWorkspaceConfig>;
|
||||
declare function defineProject(config: UserProjectConfigFn): UserProjectConfigFn;
|
||||
declare function defineProject(config: UserProjectConfigExport): UserProjectConfigExport;
|
||||
/**
|
||||
* @deprecated use the `projects` field in the root config instead
|
||||
*/
|
||||
declare function defineWorkspace(config: TestProjectConfiguration[]): TestProjectConfiguration[];
|
||||
|
||||
export { TestProjectConfiguration, UserProjectConfigExport, UserProjectConfigFn, UserWorkspaceConfig, configDefaults, coverageConfigDefaults, defaultBrowserPort, defaultExclude, defaultInclude, defineConfig, defineProject, defineWorkspace, extraInlineDeps };
|
||||
export type { UserConfig, UserConfigExport, UserConfigFn, UserConfigFnObject, UserConfigFnPromise };
|
||||
21
node_modules/vitest/dist/config.js
generated
vendored
Normal file
21
node_modules/vitest/dist/config.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
export { d as defaultBrowserPort, e as extraInlineDeps } from './chunks/constants.DnKduX2e.js';
|
||||
export { c as configDefaults, a as coverageConfigDefaults, d as defaultExclude, b as defaultInclude } from './chunks/defaults.B7q_naMc.js';
|
||||
export { mergeConfig } from 'vite';
|
||||
import 'node:os';
|
||||
import './chunks/env.D4Lgay0q.js';
|
||||
import 'std-env';
|
||||
|
||||
function defineConfig(config) {
|
||||
return config;
|
||||
}
|
||||
function defineProject(config) {
|
||||
return config;
|
||||
}
|
||||
/**
|
||||
* @deprecated use the `projects` field in the root config instead
|
||||
*/
|
||||
function defineWorkspace(config) {
|
||||
return config;
|
||||
}
|
||||
|
||||
export { defineConfig, defineProject, defineWorkspace };
|
||||
108
node_modules/vitest/dist/coverage.d.ts
generated
vendored
Normal file
108
node_modules/vitest/dist/coverage.d.ts
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, a as ReportContext } from './chunks/reporters.d.BuRON0I0.js';
|
||||
import { TransformResult } from 'vite';
|
||||
import { A as AfterSuiteRunMeta } from './chunks/environment.d.cL3nLXbE.js';
|
||||
import '@vitest/runner';
|
||||
import '@vitest/utils';
|
||||
import 'node:stream';
|
||||
import 'node:console';
|
||||
import '@vitest/mocker';
|
||||
import '@vitest/utils/source-map';
|
||||
import './chunks/worker.d.CUgIPz9V.js';
|
||||
import 'vite-node';
|
||||
import './chunks/config.d.BKdhh7Zx.js';
|
||||
import '@vitest/pretty-format';
|
||||
import '@vitest/snapshot';
|
||||
import '@vitest/snapshot/environment';
|
||||
import '@vitest/utils/diff';
|
||||
import 'chai';
|
||||
import './chunks/benchmark.d.BwvBVTda.js';
|
||||
import '@vitest/runner/utils';
|
||||
import 'tinybench';
|
||||
import './chunks/coverage.d.S9RMNXIe.js';
|
||||
import 'vite-node/client';
|
||||
import '@vitest/snapshot/manager';
|
||||
import 'node:fs';
|
||||
import 'vitest/optional-types.js';
|
||||
|
||||
type Threshold = "lines" | "functions" | "statements" | "branches";
|
||||
interface ResolvedThreshold {
|
||||
coverageMap: CoverageMap;
|
||||
name: string;
|
||||
thresholds: Partial<Record<Threshold, number | undefined>>;
|
||||
}
|
||||
/**
|
||||
* Holds info about raw coverage results that are stored on file system:
|
||||
*
|
||||
* ```json
|
||||
* "project-a": {
|
||||
* "web": {
|
||||
* "tests/math.test.ts": "coverage-1.json",
|
||||
* "tests/utils.test.ts": "coverage-2.json",
|
||||
* // ^^^^^^^^^^^^^^^ Raw coverage on file system
|
||||
* },
|
||||
* "ssr": { ... },
|
||||
* "browser": { ... },
|
||||
* },
|
||||
* "project-b": ...
|
||||
* ```
|
||||
*/
|
||||
type CoverageFiles = Map<NonNullable<AfterSuiteRunMeta["projectName"]> | symbol, Record<AfterSuiteRunMeta["transformMode"], {
|
||||
[TestFilenames: string]: string
|
||||
}>>;
|
||||
declare class BaseCoverageProvider<Options extends ResolvedCoverageOptions<"istanbul" | "v8">> {
|
||||
ctx: Vitest;
|
||||
readonly name: "v8" | "istanbul";
|
||||
version: string;
|
||||
options: Options;
|
||||
coverageFiles: CoverageFiles;
|
||||
pendingPromises: Promise<void>[];
|
||||
coverageFilesDirectory: string;
|
||||
_initialize(ctx: Vitest): void;
|
||||
createCoverageMap(): CoverageMap;
|
||||
generateReports(_: CoverageMap, __: boolean | undefined): Promise<void>;
|
||||
parseConfigModule(_: string): Promise<{
|
||||
generate: () => {
|
||||
code: string
|
||||
}
|
||||
}>;
|
||||
resolveOptions(): Options;
|
||||
clean(clean?: boolean): Promise<void>;
|
||||
onAfterSuiteRun({ coverage, transformMode, projectName, testFiles }: AfterSuiteRunMeta): void;
|
||||
readCoverageFiles<CoverageType>({ onFileRead, onFinished, onDebug }: {
|
||||
/** Callback invoked with a single coverage result */
|
||||
onFileRead: (data: CoverageType) => void
|
||||
/** Callback invoked once all results of a project for specific transform mode are read */
|
||||
onFinished: (project: Vitest["projects"][number], transformMode: AfterSuiteRunMeta["transformMode"]) => Promise<void>
|
||||
onDebug: ((...logs: any[]) => void) & {
|
||||
enabled: boolean
|
||||
}
|
||||
}): Promise<void>;
|
||||
cleanAfterRun(): Promise<void>;
|
||||
onTestFailure(): Promise<void>;
|
||||
reportCoverage(coverageMap: unknown, { allTestsRun }: ReportContext): Promise<void>;
|
||||
reportThresholds(coverageMap: CoverageMap, allTestsRun: boolean | undefined): Promise<void>;
|
||||
/**
|
||||
* Constructs collected coverage and users' threshold options into separate sets
|
||||
* where each threshold set holds their own coverage maps. Threshold set is either
|
||||
* for specific files defined by glob pattern or global for all other files.
|
||||
*/
|
||||
private resolveThresholds;
|
||||
/**
|
||||
* Check collected coverage against configured thresholds. Sets exit code to 1 when thresholds not reached.
|
||||
*/
|
||||
private checkThresholds;
|
||||
/**
|
||||
* Check if current coverage is above configured thresholds and bump the thresholds if needed
|
||||
*/
|
||||
updateThresholds({ thresholds: allThresholds, onUpdate, configurationFile }: {
|
||||
thresholds: ResolvedThreshold[]
|
||||
configurationFile: unknown
|
||||
onUpdate: () => void
|
||||
}): Promise<void>;
|
||||
mergeReports(coverageMaps: unknown[]): Promise<void>;
|
||||
hasTerminalReporter(reporters: ResolvedCoverageOptions["reporter"]): boolean;
|
||||
toSlices<T>(array: T[], size: number): T[][];
|
||||
createUncoveredFileTransformer(ctx: Vitest): (filename: string) => Promise<TransformResult | null | undefined>;
|
||||
}
|
||||
|
||||
export { BaseCoverageProvider };
|
||||
34
node_modules/vitest/dist/coverage.js
generated
vendored
Normal file
34
node_modules/vitest/dist/coverage.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
export { B as BaseCoverageProvider } from './chunks/coverage.DfSpMS-b.js';
|
||||
import 'node:fs';
|
||||
import 'pathe';
|
||||
import 'picomatch';
|
||||
import 'tinyrainbow';
|
||||
import './chunks/defaults.B7q_naMc.js';
|
||||
import 'node:os';
|
||||
import './chunks/env.D4Lgay0q.js';
|
||||
import 'std-env';
|
||||
import 'node:crypto';
|
||||
import '@vitest/utils';
|
||||
import 'node:module';
|
||||
import 'node:path';
|
||||
import 'node:process';
|
||||
import 'node:fs/promises';
|
||||
import 'node:url';
|
||||
import 'node:assert';
|
||||
import 'node:v8';
|
||||
import 'node:util';
|
||||
import 'vite';
|
||||
import './chunks/constants.DnKduX2e.js';
|
||||
import 'node:tty';
|
||||
import 'node:events';
|
||||
import './chunks/index.B521nVV-.js';
|
||||
import 'tinypool';
|
||||
import './chunks/typechecker.DRKU1-1g.js';
|
||||
import 'node:perf_hooks';
|
||||
import '@vitest/utils/source-map';
|
||||
import 'tinyexec';
|
||||
import './path.js';
|
||||
import '@vitest/runner/utils';
|
||||
import 'node:worker_threads';
|
||||
import 'vite-node/utils';
|
||||
import './chunks/coverage.DVF1vEu8.js';
|
||||
26
node_modules/vitest/dist/environments.d.ts
generated
vendored
Normal file
26
node_modules/vitest/dist/environments.d.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import { E as Environment } from './chunks/environment.d.cL3nLXbE.js';
|
||||
export { a as EnvironmentReturn, V as VmEnvironmentReturn } from './chunks/environment.d.cL3nLXbE.js';
|
||||
import 'vitest/optional-types.js';
|
||||
|
||||
declare const environments: {
|
||||
"node": Environment
|
||||
"jsdom": Environment
|
||||
"happy-dom": Environment
|
||||
"edge-runtime": Environment
|
||||
};
|
||||
|
||||
interface PopulateOptions {
|
||||
// we bind functions such as addEventListener and others
|
||||
// because they rely on `this` in happy-dom, and in jsdom it
|
||||
// has a priority for getting implementation from symbols
|
||||
// (global doesn't have these symbols, but window - does)
|
||||
bindFunctions?: boolean;
|
||||
additionalKeys?: string[];
|
||||
}
|
||||
declare function populateGlobal(global: any, win: any, options?: PopulateOptions): {
|
||||
keys: Set<string>
|
||||
skipKeys: string[]
|
||||
originals: Map<string | symbol, any>
|
||||
};
|
||||
|
||||
export { Environment, environments as builtinEnvironments, populateGlobal };
|
||||
2
node_modules/vitest/dist/environments.js
generated
vendored
Normal file
2
node_modules/vitest/dist/environments.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export { e as builtinEnvironments, p as populateGlobal } from './chunks/index.CmSc2RE5.js';
|
||||
import 'node:console';
|
||||
150
node_modules/vitest/dist/execute.d.ts
generated
vendored
Normal file
150
node_modules/vitest/dist/execute.d.ts
generated
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
import { ViteNodeRunnerOptions } from 'vite-node';
|
||||
import { ViteNodeRunner, ModuleExecutionInfo } from 'vite-node/client';
|
||||
import { R as RuntimeRPC, W as WorkerGlobalState } from './chunks/worker.d.CUgIPz9V.js';
|
||||
import vm from 'node:vm';
|
||||
import { MockedModule, MockedModuleType } from '@vitest/mocker';
|
||||
import { P as PendingSuiteMock, b as MockFactory, a as MockOptions } from './chunks/mocker.d.BE_2ls6u.js';
|
||||
import '@vitest/runner';
|
||||
import './chunks/config.d.BKdhh7Zx.js';
|
||||
import '@vitest/pretty-format';
|
||||
import '@vitest/snapshot';
|
||||
import '@vitest/snapshot/environment';
|
||||
import '@vitest/utils/diff';
|
||||
import './chunks/environment.d.cL3nLXbE.js';
|
||||
import 'vitest/optional-types.js';
|
||||
|
||||
declare class FileMap {
|
||||
private fsCache;
|
||||
private fsBufferCache;
|
||||
readFileAsync(path: string): Promise<string>;
|
||||
readFile(path: string): string;
|
||||
readBuffer(path: string): Buffer;
|
||||
}
|
||||
|
||||
// need to copy paste types for vm
|
||||
// because they require latest @types/node which we don't bundle
|
||||
interface ModuleEvaluateOptions {
|
||||
timeout?: vm.RunningScriptOptions["timeout"] | undefined;
|
||||
breakOnSigint?: vm.RunningScriptOptions["breakOnSigint"] | undefined;
|
||||
}
|
||||
type ModuleLinker = (specifier: string, referencingModule: VMModule, extra: {
|
||||
assert: object
|
||||
}) => VMModule | Promise<VMModule>;
|
||||
type ModuleStatus = "unlinked" | "linking" | "linked" | "evaluating" | "evaluated" | "errored";
|
||||
declare class VMModule {
|
||||
dependencySpecifiers: readonly string[];
|
||||
error: any;
|
||||
identifier: string;
|
||||
context: vm.Context;
|
||||
namespace: object;
|
||||
status: ModuleStatus;
|
||||
evaluate(options?: ModuleEvaluateOptions): Promise<void>;
|
||||
link(linker: ModuleLinker): Promise<void>;
|
||||
}
|
||||
|
||||
interface ExternalModulesExecutorOptions {
|
||||
context: vm.Context;
|
||||
fileMap: FileMap;
|
||||
packageCache: Map<string, any>;
|
||||
transform: RuntimeRPC["transform"];
|
||||
interopDefault?: boolean;
|
||||
viteClientModule: Record<string, unknown>;
|
||||
}
|
||||
// TODO: improve Node.js strict mode support in #2854
|
||||
declare class ExternalModulesExecutor {
|
||||
#private;
|
||||
private options;
|
||||
private cjs;
|
||||
private esm;
|
||||
private vite;
|
||||
private context;
|
||||
private fs;
|
||||
private resolvers;
|
||||
constructor(options: ExternalModulesExecutorOptions);
|
||||
import(identifier: string): Promise<object>;
|
||||
require(identifier: string): any;
|
||||
createRequire(identifier: string): NodeJS.Require;
|
||||
// dynamic import can be used in both ESM and CJS, so we have it in the executor
|
||||
importModuleDynamically: (specifier: string, referencer: VMModule) => Promise<VMModule>;
|
||||
resolveModule: (specifier: string, referencer: string) => Promise<VMModule>;
|
||||
resolve(specifier: string, parent: string): string;
|
||||
private findNearestPackageData;
|
||||
private getModuleInformation;
|
||||
private createModule;
|
||||
private get isNetworkSupported();
|
||||
}
|
||||
|
||||
interface MockContext {
|
||||
/**
|
||||
* When mocking with a factory, this refers to the module that imported the mock.
|
||||
*/
|
||||
callstack: null | string[];
|
||||
}
|
||||
declare class VitestMocker {
|
||||
executor: VitestExecutor;
|
||||
static pendingIds: PendingSuiteMock[];
|
||||
private spyModule?;
|
||||
private primitives;
|
||||
private filterPublicKeys;
|
||||
private registries;
|
||||
private mockContext;
|
||||
constructor(executor: VitestExecutor);
|
||||
private get root();
|
||||
private get moduleCache();
|
||||
private get moduleDirectories();
|
||||
initializeSpyModule(): Promise<void>;
|
||||
private getMockerRegistry;
|
||||
reset(): void;
|
||||
private deleteCachedItem;
|
||||
private isModuleDirectory;
|
||||
getSuiteFilepath(): string;
|
||||
private createError;
|
||||
private resolvePath;
|
||||
resolveMocks(): Promise<void>;
|
||||
private callFunctionMock;
|
||||
// public method to avoid circular dependency
|
||||
getMockContext(): MockContext;
|
||||
// path used to store mocked dependencies
|
||||
getMockPath(dep: string): string;
|
||||
getDependencyMock(id: string): MockedModule | undefined;
|
||||
normalizePath(path: string): string;
|
||||
resolveMockPath(mockPath: string, external: string | null): string | null;
|
||||
mockObject(object: Record<string | symbol, any>, mockExports?: Record<string | symbol, any>, behavior?: MockedModuleType): Record<string | symbol, any>;
|
||||
unmockPath(path: string): void;
|
||||
mockPath(originalId: string, path: string, external: string | null, mockType: MockedModuleType | undefined, factory: MockFactory | undefined): void;
|
||||
importActual<T>(rawId: string, importer: string, callstack?: string[] | null): Promise<T>;
|
||||
importMock(rawId: string, importee: string): Promise<any>;
|
||||
requestWithMock(url: string, callstack: string[]): Promise<any>;
|
||||
queueMock(id: string, importer: string, factoryOrOptions?: MockFactory | MockOptions): void;
|
||||
queueUnmock(id: string, importer: string): void;
|
||||
}
|
||||
|
||||
interface ExecuteOptions extends ViteNodeRunnerOptions {
|
||||
moduleDirectories?: string[];
|
||||
state: WorkerGlobalState;
|
||||
context?: vm.Context;
|
||||
externalModulesExecutor?: ExternalModulesExecutor;
|
||||
}
|
||||
declare class VitestExecutor extends ViteNodeRunner {
|
||||
options: ExecuteOptions;
|
||||
mocker: VitestMocker;
|
||||
externalModules?: ExternalModulesExecutor;
|
||||
private primitives;
|
||||
constructor(options: ExecuteOptions);
|
||||
protected getContextPrimitives(): {
|
||||
Object: typeof Object
|
||||
Reflect: typeof Reflect
|
||||
Symbol: typeof Symbol
|
||||
};
|
||||
get state(): WorkerGlobalState;
|
||||
get moduleExecutionInfo(): ModuleExecutionInfo | undefined;
|
||||
shouldResolveId(id: string, _importee?: string | undefined): boolean;
|
||||
originalResolveUrl(id: string, importer?: string): Promise<[url: string, fsPath: string]>;
|
||||
resolveUrl(id: string, importer?: string): Promise<[url: string, fsPath: string]>;
|
||||
protected runModule(context: Record<string, any>, transformed: string): Promise<void>;
|
||||
importExternalModule(path: string): Promise<any>;
|
||||
dependencyRequest(id: string, fsPath: string, callstack: string[]): Promise<any>;
|
||||
prepareContext(context: Record<string, any>): Record<string, any>;
|
||||
}
|
||||
|
||||
export { VitestExecutor };
|
||||
13
node_modules/vitest/dist/execute.js
generated
vendored
Normal file
13
node_modules/vitest/dist/execute.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
export { V as VitestExecutor } from './chunks/execute.B7h3T_Hc.js';
|
||||
import 'node:fs';
|
||||
import 'node:url';
|
||||
import 'node:vm';
|
||||
import '@vitest/utils/error';
|
||||
import 'pathe';
|
||||
import 'vite-node/client';
|
||||
import 'vite-node/utils';
|
||||
import './path.js';
|
||||
import 'node:path';
|
||||
import '@vitest/mocker';
|
||||
import 'node:module';
|
||||
import '@vitest/utils';
|
||||
651
node_modules/vitest/dist/index.d.ts
generated
vendored
Normal file
651
node_modules/vitest/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,651 @@
|
||||
import { File as File$1, TestAnnotation, TaskResultPack as TaskResultPack$1, TaskEventPack, TaskPopulated, Suite as Suite$1, Test as Test$1, Custom as Custom$1, Task as Task$1, TaskBase as TaskBase$1, TaskResult as TaskResult$1, DoneCallback as DoneCallback$1, RuntimeContext as RuntimeContext$1, SuiteHooks as SuiteHooks$1, SequenceHooks as SequenceHooks$1, SequenceSetupFiles as SequenceSetupFiles$1 } from '@vitest/runner';
|
||||
export { CancelReason, ExtendedContext, HookCleanupCallback, HookListener, ImportDuration, OnTestFailedHandler, OnTestFinishedHandler, RunMode, Custom as RunnerCustomCase, Task as RunnerTask, TaskBase as RunnerTaskBase, TaskEventPack as RunnerTaskEventPack, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SuiteAPI, SuiteCollector, SuiteFactory, TaskContext, TaskCustomOptions, TaskMeta, TaskState, TestAPI, TestAnnotation, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
||||
import { S as SerializedTestSpecification, h as CoverageProvider$1, a as ReportContext$1, i as CoverageProviderModule$1, j as CoverageReporter$1, k as CoverageProviderName, l as CoverageOptions$1, R as ResolvedCoverageOptions$1, B as BaseCoverageOptions$1, m as CoverageIstanbulOptions$1, c as CoverageV8Options$1, n as CustomProviderOptions$1, o as Reporter$1, V as Vitest$1, p as BrowserScript$1, q as BrowserConfigOptions$1, r as BuiltinEnvironment$1, s as VitestEnvironment$1, P as Pool$1, t as PoolOptions$1, u as CSSModuleScopeStrategy$1, A as ApiConfig$1, v as VitestRunMode$1, D as DepsOptimizationOptions$1, w as TransformModePatterns$1, I as InlineConfig$1, x as TypecheckConfig$1, y as UserConfig$1, z as ResolvedConfig$1, E as ProjectConfig$1, U as UserWorkspaceConfig$1, F as BenchmarkUserOptions$1 } from './chunks/reporters.d.BuRON0I0.js';
|
||||
export { G as BrowserTesterOptions } from './chunks/reporters.d.BuRON0I0.js';
|
||||
import { W as WorkerContext$1 } from './chunks/worker.d.uzWsCv9X.js';
|
||||
import { R as RawErrsMap$1, T as TscErrorInfo$1, C as CollectLineNumbers$1, a as CollectLines$1, b as RootAndTarget$1, c as Context$1 } from './chunks/global.d.MAmajcmJ.js';
|
||||
import { b as Awaitable$1, U as UserConsoleLog, L as LabelColor, M as ModuleGraphData, P as ProvidedContext, N as Nullable$1, c as Arrayable$1, d as ArgumentsType$1, e as MutableArray$1, C as Constructable$1, a as EnvironmentReturn$1, V as VmEnvironmentReturn$1, E as Environment$1, R as ResolvedTestEnvironment$1, J as JSDOMOptions$1, H as HappyDOMOptions$1, f as EnvironmentOptions$1 } from './chunks/environment.d.cL3nLXbE.js';
|
||||
export { A as AfterSuiteRunMeta, g as ModuleCache } from './chunks/environment.d.cL3nLXbE.js';
|
||||
import { a as BirpcReturn, b as WorkerRPC$1 } from './chunks/worker.d.CUgIPz9V.js';
|
||||
export { C as ContextRPC, d as ContextTestEnvironment, e as ResolveIdFunction, c as RunnerRPC, R as RuntimeRPC, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.CUgIPz9V.js';
|
||||
import './chunks/vite.d.BnOPPc46.js';
|
||||
import { a as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.d.BKdhh7Zx.js';
|
||||
export { b as RuntimeConfig, S as SerializedCoverageConfig } from './chunks/config.d.BKdhh7Zx.js';
|
||||
import { ExpectStatic } from '@vitest/expect';
|
||||
export { Assertion, AsymmetricMatchersContaining, DeeplyAllowMatchers, ExpectPollOptions, ExpectStatic, JestAssertion, Matchers } from '@vitest/expect';
|
||||
import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy';
|
||||
export { Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject } from '@vitest/spy';
|
||||
import { M as MockFactoryWithHelper, a as MockOptions } from './chunks/mocker.d.BE_2ls6u.js';
|
||||
export { b as bench } from './chunks/suite.d.FvehnV49.js';
|
||||
export { a as BenchFunction, b as Benchmark, c as BenchmarkAPI, B as BenchmarkResult } from './chunks/benchmark.d.BwvBVTda.js';
|
||||
export { ExpectTypeOf, expectTypeOf } from 'expect-type';
|
||||
export { SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotSerializer, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, UncheckedSnapshot } from '@vitest/snapshot';
|
||||
export { ErrorWithDiff, ParsedStack, SerializedError, TestError } from '@vitest/utils';
|
||||
export { DiffOptions } from '@vitest/utils/diff';
|
||||
import * as chai from 'chai';
|
||||
export { chai };
|
||||
export { assert, should } from 'chai';
|
||||
export { Bench as BenchFactory, Options as BenchOptions, Task as BenchTask, TaskResult as BenchTaskResult } from 'tinybench';
|
||||
import 'node:stream';
|
||||
import 'vite';
|
||||
import 'node:console';
|
||||
import '@vitest/mocker';
|
||||
import '@vitest/utils/source-map';
|
||||
import '@vitest/pretty-format';
|
||||
import 'vite-node';
|
||||
import './chunks/coverage.d.S9RMNXIe.js';
|
||||
import 'vite-node/client';
|
||||
import '@vitest/snapshot/manager';
|
||||
import 'node:fs';
|
||||
import 'node:worker_threads';
|
||||
import 'vitest/optional-types.js';
|
||||
import '@vitest/snapshot/environment';
|
||||
import '@vitest/runner/utils';
|
||||
|
||||
interface SourceMap {
|
||||
file: string;
|
||||
mappings: string;
|
||||
names: string[];
|
||||
sources: string[];
|
||||
sourcesContent?: string[];
|
||||
version: number;
|
||||
toString: () => string;
|
||||
toUrl: () => string;
|
||||
}
|
||||
interface TransformResultWithSource {
|
||||
code: string;
|
||||
map: SourceMap | {
|
||||
mappings: ""
|
||||
} | null;
|
||||
etag?: string;
|
||||
deps?: string[];
|
||||
dynamicDeps?: string[];
|
||||
source?: string;
|
||||
}
|
||||
interface WebSocketHandlers {
|
||||
onTaskUpdate: (packs: TaskResultPack$1[], events: TaskEventPack[]) => void;
|
||||
getFiles: () => File$1[];
|
||||
getTestFiles: () => Promise<SerializedTestSpecification[]>;
|
||||
getPaths: () => string[];
|
||||
getConfig: () => SerializedConfig;
|
||||
// TODO: Remove in v4
|
||||
/** @deprecated -- Use `getResolvedProjectLabels` instead */
|
||||
getResolvedProjectNames: () => string[];
|
||||
getResolvedProjectLabels: () => {
|
||||
name: string
|
||||
color?: LabelColor
|
||||
}[];
|
||||
getModuleGraph: (projectName: string, id: string, browser?: boolean) => Promise<ModuleGraphData>;
|
||||
getTransformResult: (projectName: string, id: string, browser?: boolean) => Promise<TransformResultWithSource | undefined>;
|
||||
readTestFile: (id: string) => Promise<string | null>;
|
||||
saveTestFile: (id: string, content: string) => Promise<void>;
|
||||
rerun: (files: string[], resetTestNamePattern?: boolean) => Promise<void>;
|
||||
rerunTask: (id: string) => Promise<void>;
|
||||
updateSnapshot: (file?: File$1) => Promise<void>;
|
||||
getUnhandledErrors: () => unknown[];
|
||||
}
|
||||
interface WebSocketEvents {
|
||||
onCollected?: (files?: File$1[]) => Awaitable$1<void>;
|
||||
onFinished?: (files: File$1[], errors: unknown[], coverage?: unknown) => Awaitable$1<void>;
|
||||
onTestAnnotate?: (testId: string, annotation: TestAnnotation) => Awaitable$1<void>;
|
||||
onTaskUpdate?: (packs: TaskResultPack$1[], events: TaskEventPack[]) => Awaitable$1<void>;
|
||||
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable$1<void>;
|
||||
onPathsCollected?: (paths?: string[]) => Awaitable$1<void>;
|
||||
onSpecsCollected?: (specs?: SerializedTestSpecification[]) => Awaitable$1<void>;
|
||||
onFinishedReportCoverage: () => void;
|
||||
}
|
||||
type WebSocketRPC = BirpcReturn<WebSocketEvents, WebSocketHandlers>;
|
||||
|
||||
// CI fails only for this file, but it works locally
|
||||
|
||||
declare function createExpect(test?: TaskPopulated): ExpectStatic;
|
||||
declare const globalExpect: ExpectStatic;
|
||||
|
||||
/**
|
||||
* Gives access to injected context provided from the main thread.
|
||||
* This usually returns a value provided by `globalSetup` or an external library.
|
||||
*/
|
||||
declare function inject<T extends keyof ProvidedContext & string>(key: T): ProvidedContext[T];
|
||||
|
||||
// The waitFor function was inspired by https://github.com/testing-library/web-testing-library/pull/2
|
||||
type WaitForCallback<T> = () => T | Promise<T>;
|
||||
interface WaitForOptions {
|
||||
/**
|
||||
* @description Time in ms between each check callback
|
||||
* @default 50ms
|
||||
*/
|
||||
interval?: number;
|
||||
/**
|
||||
* @description Time in ms after which the throw a timeout error
|
||||
* @default 1000ms
|
||||
*/
|
||||
timeout?: number;
|
||||
}
|
||||
declare function waitFor<T>(callback: WaitForCallback<T>, options?: number | WaitForOptions): Promise<T>;
|
||||
type WaitUntilCallback<T> = () => T | Promise<T>;
|
||||
interface WaitUntilOptions extends Pick<WaitForOptions, "interval" | "timeout"> {}
|
||||
type Truthy<T> = T extends false | "" | 0 | null | undefined ? never : T;
|
||||
declare function waitUntil<T>(callback: WaitUntilCallback<T>, options?: number | WaitUntilOptions): Promise<Truthy<T>>;
|
||||
|
||||
type ESModuleExports = Record<string, unknown>;
|
||||
interface VitestUtils {
|
||||
/**
|
||||
* Checks if fake timers are enabled.
|
||||
*/
|
||||
isFakeTimers: () => boolean;
|
||||
/**
|
||||
* This method wraps all further calls to timers until [`vi.useRealTimers()`](https://vitest.dev/api/vi#vi-userealtimers) is called.
|
||||
*/
|
||||
useFakeTimers: (config?: FakeTimerInstallOpts) => VitestUtils;
|
||||
/**
|
||||
* Restores mocked timers to their original implementations. All timers that were scheduled before will be discarded.
|
||||
*/
|
||||
useRealTimers: () => VitestUtils;
|
||||
/**
|
||||
* This method will call every timer that was initiated after [`vi.useFakeTimers`](https://vitest.dev/api/vi#vi-usefaketimers) call.
|
||||
* It will not fire any timer that was initiated during its call.
|
||||
*/
|
||||
runOnlyPendingTimers: () => VitestUtils;
|
||||
/**
|
||||
* This method will asynchronously call every timer that was initiated after [`vi.useFakeTimers`](https://vitest.dev/api/vi#vi-usefaketimers) call, even asynchronous ones.
|
||||
* It will not fire any timer that was initiated during its call.
|
||||
*/
|
||||
runOnlyPendingTimersAsync: () => Promise<VitestUtils>;
|
||||
/**
|
||||
* This method will invoke every initiated timer until the timer queue is empty. It means that every timer called during `runAllTimers` will be fired.
|
||||
* If you have an infinite interval, it will throw after 10,000 tries (can be configured with [`fakeTimers.loopLimit`](https://vitest.dev/config/#faketimers-looplimit)).
|
||||
*/
|
||||
runAllTimers: () => VitestUtils;
|
||||
/**
|
||||
* This method will asynchronously invoke every initiated timer until the timer queue is empty. It means that every timer called during `runAllTimersAsync` will be fired even asynchronous timers.
|
||||
* If you have an infinite interval, it will throw after 10 000 tries (can be configured with [`fakeTimers.loopLimit`](https://vitest.dev/config/#faketimers-looplimit)).
|
||||
*/
|
||||
runAllTimersAsync: () => Promise<VitestUtils>;
|
||||
/**
|
||||
* Calls every microtask that was queued by `process.nextTick`. This will also run all microtasks scheduled by themselves.
|
||||
*/
|
||||
runAllTicks: () => VitestUtils;
|
||||
/**
|
||||
* This method will invoke every initiated timer until the specified number of milliseconds is passed or the queue is empty - whatever comes first.
|
||||
*/
|
||||
advanceTimersByTime: (ms: number) => VitestUtils;
|
||||
/**
|
||||
* This method will invoke every initiated timer until the specified number of milliseconds is passed or the queue is empty - whatever comes first. This will include and await asynchronously set timers.
|
||||
*/
|
||||
advanceTimersByTimeAsync: (ms: number) => Promise<VitestUtils>;
|
||||
/**
|
||||
* Will call next available timer. Useful to make assertions between each timer call. You can chain call it to manage timers by yourself.
|
||||
*/
|
||||
advanceTimersToNextTimer: () => VitestUtils;
|
||||
/**
|
||||
* Will call next available timer and wait until it's resolved if it was set asynchronously. Useful to make assertions between each timer call.
|
||||
*/
|
||||
advanceTimersToNextTimerAsync: () => Promise<VitestUtils>;
|
||||
/**
|
||||
* Similar to [`vi.advanceTimersByTime`](https://vitest.dev/api/vi#vi-advancetimersbytime), but will advance timers by the milliseconds needed to execute callbacks currently scheduled with `requestAnimationFrame`.
|
||||
*/
|
||||
advanceTimersToNextFrame: () => VitestUtils;
|
||||
/**
|
||||
* Get the number of waiting timers.
|
||||
*/
|
||||
getTimerCount: () => number;
|
||||
/**
|
||||
* If fake timers are enabled, this method simulates a user changing the system clock (will affect date related API like `hrtime`, `performance.now` or `new Date()`) - however, it will not fire any timers.
|
||||
* If fake timers are not enabled, this method will only mock `Date.*` and `new Date()` calls.
|
||||
*/
|
||||
setSystemTime: (time: number | string | Date) => VitestUtils;
|
||||
/**
|
||||
* Returns mocked current date. If date is not mocked the method will return `null`.
|
||||
*/
|
||||
getMockedSystemTime: () => Date | null;
|
||||
/**
|
||||
* When using `vi.useFakeTimers`, `Date.now` calls are mocked. If you need to get real time in milliseconds, you can call this function.
|
||||
*/
|
||||
getRealSystemTime: () => number;
|
||||
/**
|
||||
* Removes all timers that are scheduled to run. These timers will never run in the future.
|
||||
*/
|
||||
clearAllTimers: () => VitestUtils;
|
||||
/**
|
||||
* Creates a spy on a method or getter/setter of an object similar to [`vi.fn()`](https://vitest.dev/api/vi#vi-fn). It returns a [mock function](https://vitest.dev/api/mock).
|
||||
* @example
|
||||
* ```ts
|
||||
* const cart = {
|
||||
* getApples: () => 42
|
||||
* }
|
||||
*
|
||||
* const spy = vi.spyOn(cart, 'getApples').mockReturnValue(10)
|
||||
*
|
||||
* expect(cart.getApples()).toBe(10)
|
||||
* expect(spy).toHaveBeenCalled()
|
||||
* expect(spy).toHaveReturnedWith(10)
|
||||
* ```
|
||||
*/
|
||||
spyOn: typeof spyOn;
|
||||
/**
|
||||
* Creates a spy on a function, though can be initiated without one. Every time a function is invoked, it stores its call arguments, returns, and instances. Also, you can manipulate its behavior with [methods](https://vitest.dev/api/mock).
|
||||
*
|
||||
* If no function is given, mock will return `undefined`, when invoked.
|
||||
* @example
|
||||
* ```ts
|
||||
* const getApples = vi.fn(() => 0)
|
||||
*
|
||||
* getApples()
|
||||
*
|
||||
* expect(getApples).toHaveBeenCalled()
|
||||
* expect(getApples).toHaveReturnedWith(0)
|
||||
*
|
||||
* getApples.mockReturnValueOnce(5)
|
||||
*
|
||||
* expect(getApples()).toBe(5)
|
||||
* expect(getApples).toHaveNthReturnedWith(2, 5)
|
||||
* ```
|
||||
*/
|
||||
fn: typeof fn;
|
||||
/**
|
||||
* Wait for the callback to execute successfully. If the callback throws an error or returns a rejected promise it will continue to wait until it succeeds or times out.
|
||||
*
|
||||
* This is very useful when you need to wait for some asynchronous action to complete, for example, when you start a server and need to wait for it to start.
|
||||
* @example
|
||||
* ```ts
|
||||
* const server = createServer()
|
||||
*
|
||||
* await vi.waitFor(
|
||||
* () => {
|
||||
* if (!server.isReady)
|
||||
* throw new Error('Server not started')
|
||||
*
|
||||
* console.log('Server started')
|
||||
* }, {
|
||||
* timeout: 500, // default is 1000
|
||||
* interval: 20, // default is 50
|
||||
* }
|
||||
* )
|
||||
* ```
|
||||
*/
|
||||
waitFor: typeof waitFor;
|
||||
/**
|
||||
* This is similar to [`vi.waitFor`](https://vitest.dev/api/vi#vi-waitfor), but if the callback throws any errors, execution is immediately interrupted and an error message is received.
|
||||
*
|
||||
* If the callback returns a falsy value, the next check will continue until a truthy value is returned. This is useful when you need to wait for something to exist before taking the next step.
|
||||
* @example
|
||||
* ```ts
|
||||
* const element = await vi.waitUntil(
|
||||
* () => document.querySelector('.element'),
|
||||
* {
|
||||
* timeout: 500, // default is 1000
|
||||
* interval: 20, // default is 50
|
||||
* }
|
||||
* )
|
||||
*
|
||||
* // do something with the element
|
||||
* expect(element.querySelector('.element-child')).toBeTruthy()
|
||||
* ```
|
||||
*/
|
||||
waitUntil: typeof waitUntil;
|
||||
/**
|
||||
* Run the factory before imports are evaluated. You can return a value from the factory
|
||||
* to reuse it inside your [`vi.mock`](https://vitest.dev/api/vi#vi-mock) factory and tests.
|
||||
*
|
||||
* If used with [`vi.mock`](https://vitest.dev/api/vi#vi-mock), both will be hoisted in the order they are defined in.
|
||||
*/
|
||||
hoisted: <T>(factory: () => T) => T;
|
||||
/**
|
||||
* Mocks every import call to the module even if it was already statically imported.
|
||||
*
|
||||
* The call to `vi.mock` is hoisted to the top of the file, so you don't have access to variables declared in the global file scope
|
||||
* unless they are defined with [`vi.hoisted`](https://vitest.dev/api/vi#vi-hoisted) before this call.
|
||||
*
|
||||
* Mocking algorithm is described in [documentation](https://vitest.dev/guide/mocking#modules).
|
||||
* @param path Path to the module. Can be aliased, if your Vitest config supports it
|
||||
* @param factory Mocked module factory. The result of this function will be an exports object
|
||||
*/
|
||||
// eslint-disable-next-line ts/method-signature-style
|
||||
mock(path: string, factory?: MockFactoryWithHelper | MockOptions): void;
|
||||
// eslint-disable-next-line ts/method-signature-style
|
||||
mock<T>(module: Promise<T>, factory?: MockFactoryWithHelper<T> | MockOptions): void;
|
||||
/**
|
||||
* Removes module from mocked registry. All calls to import will return the original module even if it was mocked before.
|
||||
*
|
||||
* This call is hoisted to the top of the file, so it will only unmock modules that were defined in `setupFiles`, for example.
|
||||
* @param path Path to the module. Can be aliased, if your Vitest config supports it
|
||||
*/
|
||||
// eslint-disable-next-line ts/method-signature-style
|
||||
unmock(path: string): void;
|
||||
// eslint-disable-next-line ts/method-signature-style
|
||||
unmock(module: Promise<unknown>): void;
|
||||
/**
|
||||
* Mocks every subsequent [dynamic import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) call.
|
||||
*
|
||||
* Unlike [`vi.mock`](https://vitest.dev/api/vi#vi-mock), this method will not mock statically imported modules because it is not hoisted to the top of the file.
|
||||
*
|
||||
* Mocking algorithm is described in [documentation](https://vitest.dev/guide/mocking#modules).
|
||||
* @param path Path to the module. Can be aliased, if your Vitest config supports it
|
||||
* @param factory Mocked module factory. The result of this function will be an exports object
|
||||
*/
|
||||
// eslint-disable-next-line ts/method-signature-style
|
||||
doMock(path: string, factory?: MockFactoryWithHelper | MockOptions): void;
|
||||
// eslint-disable-next-line ts/method-signature-style
|
||||
doMock<T>(module: Promise<T>, factory?: MockFactoryWithHelper<T> | MockOptions): void;
|
||||
/**
|
||||
* Removes module from mocked registry. All subsequent calls to import will return original module.
|
||||
*
|
||||
* Unlike [`vi.unmock`](https://vitest.dev/api/vi#vi-unmock), this method is not hoisted to the top of the file.
|
||||
* @param path Path to the module. Can be aliased, if your Vitest config supports it
|
||||
*/
|
||||
// eslint-disable-next-line ts/method-signature-style
|
||||
doUnmock(path: string): void;
|
||||
// eslint-disable-next-line ts/method-signature-style
|
||||
doUnmock(module: Promise<unknown>): void;
|
||||
/**
|
||||
* Imports module, bypassing all checks if it should be mocked.
|
||||
* Can be useful if you want to mock module partially.
|
||||
* @example
|
||||
* ```ts
|
||||
* vi.mock('./example.js', async () => {
|
||||
* const axios = await vi.importActual<typeof import('./example.js')>('./example.js')
|
||||
*
|
||||
* return { ...axios, get: vi.fn() }
|
||||
* })
|
||||
* ```
|
||||
* @param path Path to the module. Can be aliased, if your config supports it
|
||||
*/
|
||||
importActual: <T = ESModuleExports>(path: string) => Promise<T>;
|
||||
/**
|
||||
* Imports a module with all of its properties and nested properties mocked.
|
||||
*
|
||||
* Mocking algorithm is described in [documentation](https://vitest.dev/guide/mocking#modules).
|
||||
* @example
|
||||
* ```ts
|
||||
* const example = await vi.importMock<typeof import('./example.js')>('./example.js')
|
||||
* example.calc.mockReturnValue(10)
|
||||
* expect(example.calc()).toBe(10)
|
||||
* ```
|
||||
* @param path Path to the module. Can be aliased, if your config supports it
|
||||
* @returns Fully mocked module
|
||||
*/
|
||||
importMock: <T = ESModuleExports>(path: string) => Promise<MaybeMockedDeep<T>>;
|
||||
/**
|
||||
* Deeply mocks properties and methods of a given object
|
||||
* in the same way as `vi.mock()` mocks module exports.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const original = {
|
||||
* simple: () => 'value',
|
||||
* nested: {
|
||||
* method: () => 'real'
|
||||
* },
|
||||
* prop: 'foo',
|
||||
* }
|
||||
*
|
||||
* const mocked = vi.mockObject(original)
|
||||
* expect(mocked.simple()).toBe(undefined)
|
||||
* expect(mocked.nested.method()).toBe(undefined)
|
||||
* expect(mocked.prop).toBe('foo')
|
||||
*
|
||||
* mocked.simple.mockReturnValue('mocked')
|
||||
* mocked.nested.method.mockReturnValue('mocked nested')
|
||||
*
|
||||
* expect(mocked.simple()).toBe('mocked')
|
||||
* expect(mocked.nested.method()).toBe('mocked nested')
|
||||
* ```
|
||||
*
|
||||
* @param value - The object to be mocked
|
||||
* @returns A deeply mocked version of the input object
|
||||
*/
|
||||
mockObject: <T>(value: T) => MaybeMockedDeep<T>;
|
||||
/**
|
||||
* Type helper for TypeScript. Just returns the object that was passed.
|
||||
*
|
||||
* When `partial` is `true` it will expect a `Partial<T>` as a return value. By default, this will only make TypeScript believe that
|
||||
* the first level values are mocked. You can pass down `{ deep: true }` as a second argument to tell TypeScript that the whole object is mocked, if it actually is.
|
||||
* @example
|
||||
* ```ts
|
||||
* import example from './example.js'
|
||||
* vi.mock('./example.js')
|
||||
*
|
||||
* test('1 + 1 equals 10' async () => {
|
||||
* vi.mocked(example.calc).mockReturnValue(10)
|
||||
* expect(example.calc(1, '+', 1)).toBe(10)
|
||||
* })
|
||||
* ```
|
||||
* @param item Anything that can be mocked
|
||||
* @param deep If the object is deeply mocked
|
||||
* @param options If the object is partially or deeply mocked
|
||||
*/
|
||||
mocked: (<T>(item: T, deep?: false) => MaybeMocked<T>) & (<T>(item: T, deep: true) => MaybeMockedDeep<T>) & (<T>(item: T, options: {
|
||||
partial?: false
|
||||
deep?: false
|
||||
}) => MaybeMocked<T>) & (<T>(item: T, options: {
|
||||
partial?: false
|
||||
deep: true
|
||||
}) => MaybeMockedDeep<T>) & (<T>(item: T, options: {
|
||||
partial: true
|
||||
deep?: false
|
||||
}) => MaybePartiallyMocked<T>) & (<T>(item: T, options: {
|
||||
partial: true
|
||||
deep: true
|
||||
}) => MaybePartiallyMockedDeep<T>) & (<T>(item: T) => MaybeMocked<T>);
|
||||
/**
|
||||
* Checks that a given parameter is a mock function. If you are using TypeScript, it will also narrow down its type.
|
||||
*/
|
||||
isMockFunction: (fn: any) => fn is MockInstance;
|
||||
/**
|
||||
* Calls [`.mockClear()`](https://vitest.dev/api/mock#mockclear) on every mocked function.
|
||||
*
|
||||
* This will only empty `.mock` state, it will not affect mock implementations.
|
||||
*
|
||||
* This is useful if you need to clean up mocks between different assertions within a test.
|
||||
*/
|
||||
clearAllMocks: () => VitestUtils;
|
||||
/**
|
||||
* Calls [`.mockReset()`](https://vitest.dev/api/mock#mockreset) on every mocked function.
|
||||
*
|
||||
* This will empty `.mock` state, reset "once" implementations, and reset each mock's base implementation to its original.
|
||||
*
|
||||
* This is useful when you want to reset all mocks to their original states.
|
||||
*/
|
||||
resetAllMocks: () => VitestUtils;
|
||||
/**
|
||||
* Calls [`.mockRestore()`](https://vitest.dev/api/mock#mockrestore) on every mocked function.
|
||||
*
|
||||
* This will empty `.mock` state, restore all original mock implementations, and restore original descriptors of spied-on objects.
|
||||
*
|
||||
* This is useful for inter-test cleanup and/or removing mocks created by [`vi.spyOn(...)`](https://vitest.dev/api/vi#vi-spyon).
|
||||
*/
|
||||
restoreAllMocks: () => VitestUtils;
|
||||
/**
|
||||
* Makes value available on global namespace.
|
||||
* Useful, if you want to have global variables available, like `IntersectionObserver`.
|
||||
* You can return it back to original value with `vi.unstubAllGlobals`, or by enabling `unstubGlobals` config option.
|
||||
*/
|
||||
stubGlobal: (name: string | symbol | number, value: unknown) => VitestUtils;
|
||||
/**
|
||||
* Changes the value of `import.meta.env` and `process.env`.
|
||||
* You can return it back to original value with `vi.unstubAllEnvs`, or by enabling `unstubEnvs` config option.
|
||||
*/
|
||||
stubEnv: <T extends string>(name: T, value: T extends "PROD" | "DEV" | "SSR" ? boolean : string | undefined) => VitestUtils;
|
||||
/**
|
||||
* Reset the value to original value that was available before first `vi.stubGlobal` was called.
|
||||
*/
|
||||
unstubAllGlobals: () => VitestUtils;
|
||||
/**
|
||||
* Reset environmental variables to the ones that were available before first `vi.stubEnv` was called.
|
||||
*/
|
||||
unstubAllEnvs: () => VitestUtils;
|
||||
/**
|
||||
* Resets modules registry by clearing the cache of all modules. This allows modules to be reevaluated when reimported.
|
||||
* Top-level imports cannot be re-evaluated. Might be useful to isolate modules where local state conflicts between tests.
|
||||
*
|
||||
* This method does not reset mocks registry. To clear mocks registry, use [`vi.unmock`](https://vitest.dev/api/vi#vi-unmock) or [`vi.doUnmock`](https://vitest.dev/api/vi#vi-dounmock).
|
||||
*/
|
||||
resetModules: () => VitestUtils;
|
||||
/**
|
||||
* Wait for all imports to load. Useful, if you have a synchronous call that starts
|
||||
* importing a module that you cannot await otherwise.
|
||||
* Will also wait for new imports, started during the wait.
|
||||
*/
|
||||
dynamicImportSettled: () => Promise<void>;
|
||||
/**
|
||||
* Updates runtime config. You can only change values that are used when executing tests.
|
||||
*/
|
||||
setConfig: (config: RuntimeOptions) => void;
|
||||
/**
|
||||
* If config was changed with `vi.setConfig`, this will reset it to the original state.
|
||||
*/
|
||||
resetConfig: () => void;
|
||||
}
|
||||
declare const vitest: VitestUtils;
|
||||
declare const vi: VitestUtils;
|
||||
|
||||
interface AssertType {
|
||||
<T>(value: T): void;
|
||||
}
|
||||
declare const assertType: AssertType;
|
||||
|
||||
interface BrowserUI {
|
||||
setCurrentFileId: (fileId: string) => void;
|
||||
setIframeViewport: (width: number, height: number) => Promise<void>;
|
||||
}
|
||||
|
||||
/** @deprecated import `TypeCheckRawErrorsMap` from `vitest/node` instead */
|
||||
type RawErrsMap = RawErrsMap$1;
|
||||
/** @deprecated import `TypeCheckErrorInfo` from `vitest/node` instead */
|
||||
type TscErrorInfo = TscErrorInfo$1;
|
||||
/** @deprecated import `TypeCheckCollectLineNumbers` from `vitest/node` instead */
|
||||
type CollectLineNumbers = CollectLineNumbers$1;
|
||||
/** @deprecated import `TypeCheckCollectLines` from `vitest/node` instead */
|
||||
type CollectLines = CollectLines$1;
|
||||
/** @deprecated import `TypeCheckRootAndTarget` from `vitest/node` instead */
|
||||
type RootAndTarget = RootAndTarget$1;
|
||||
/** @deprecated import `TypeCheckContext` from `vitest/node` instead */
|
||||
type Context = Context$1;
|
||||
/** @deprecated use `RunnerTestSuite` instead */
|
||||
type Suite = Suite$1;
|
||||
/** @deprecated use `RunnerTestFile` instead */
|
||||
type File = File$1;
|
||||
/** @deprecated use `RunnerTestCase` instead */
|
||||
type Test = Test$1;
|
||||
/** @deprecated do not use `Custom`, use `RunnerTestCase` instead */
|
||||
type Custom = Custom$1;
|
||||
/** @deprecated use `RunnerTask` instead */
|
||||
type Task = Task$1;
|
||||
/** @deprecated use `RunnerTaskBase` instead */
|
||||
type TaskBase = TaskBase$1;
|
||||
/** @deprecated use `RunnerTaskResult` instead */
|
||||
type TaskResult = TaskResult$1;
|
||||
/** @deprecated use `RunnerTaskResultPack` instead */
|
||||
type TaskResultPack = TaskResultPack$1;
|
||||
/** @deprecated don't use `DoneCallback` since it's not supported */
|
||||
type DoneCallback = DoneCallback$1;
|
||||
/** @deprecated internal type, don't use it */
|
||||
type RuntimeContext = RuntimeContext$1;
|
||||
/** @deprecated internal type, don't use it */
|
||||
type SuiteHooks = SuiteHooks$1;
|
||||
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type WorkerContext = WorkerContext$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type WorkerRPC = WorkerRPC$1;
|
||||
|
||||
/** @deprecated do not use, internal helper */
|
||||
type Awaitable<T> = Awaitable$1<T>;
|
||||
/** @deprecated do not use, internal helper */
|
||||
type Nullable<T> = Nullable$1<T>;
|
||||
/** @deprecated do not use, internal helper */
|
||||
type Arrayable<T> = Arrayable$1<T>;
|
||||
/** @deprecated do not use, internal helper */
|
||||
type ArgumentsType<T> = ArgumentsType$1<T>;
|
||||
/** @deprecated do not use, internal helper */
|
||||
type MutableArray<T extends readonly any[]> = MutableArray$1<T>;
|
||||
/** @deprecated do not use, internal helper */
|
||||
type Constructable = Constructable$1;
|
||||
|
||||
/** @deprecated import from `vitest/environments` instead */
|
||||
type EnvironmentReturn = EnvironmentReturn$1;
|
||||
/** @deprecated import from `vitest/environments` instead */
|
||||
type VmEnvironmentReturn = VmEnvironmentReturn$1;
|
||||
/** @deprecated import from `vitest/environments` instead */
|
||||
type Environment = Environment$1;
|
||||
/** @deprecated do not use it */
|
||||
type ResolvedTestEnvironment = ResolvedTestEnvironment$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type CoverageProvider = CoverageProvider$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type ReportContext = ReportContext$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type CoverageProviderModule = CoverageProviderModule$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type CoverageReporter = CoverageReporter$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type CoverageOptions<T extends CoverageProviderName = CoverageProviderName> = CoverageOptions$1<T>;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type ResolvedCoverageOptions<T extends CoverageProviderName = CoverageProviderName> = ResolvedCoverageOptions$1<T>;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type BaseCoverageOptions = BaseCoverageOptions$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type CoverageIstanbulOptions = CoverageIstanbulOptions$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type CoverageV8Options = CoverageV8Options$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type CustomProviderOptions = CustomProviderOptions$1;
|
||||
|
||||
/** @deprecated import from `vitest/reporter` instead */
|
||||
type Reporter = Reporter$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type Vitest = Vitest$1;
|
||||
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type BrowserScript = BrowserScript$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type BrowserConfigOptions = BrowserConfigOptions$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type SequenceHooks = SequenceHooks$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type SequenceSetupFiles = SequenceSetupFiles$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type BuiltinEnvironment = BuiltinEnvironment$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type VitestEnvironment = VitestEnvironment$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type Pool = Pool$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type PoolOptions = PoolOptions$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type CSSModuleScopeStrategy = CSSModuleScopeStrategy$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type ApiConfig = ApiConfig$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type JSDOMOptions = JSDOMOptions$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type HappyDOMOptions = HappyDOMOptions$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type EnvironmentOptions = EnvironmentOptions$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type VitestRunMode = VitestRunMode$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type DepsOptimizationOptions = DepsOptimizationOptions$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type TransformModePatterns = TransformModePatterns$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type InlineConfig = InlineConfig$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type TypecheckConfig = TypecheckConfig$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type UserConfig = UserConfig$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type ResolvedConfig = ResolvedConfig$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type ProjectConfig = ProjectConfig$1;
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type UserWorkspaceConfig = UserWorkspaceConfig$1;
|
||||
|
||||
/** @deprecated use `SerializedTestSpecification` instead */
|
||||
type SerializableSpec = SerializedTestSpecification;
|
||||
|
||||
/** @deprecated import from `vitest/node` instead */
|
||||
type BenchmarkUserOptions = BenchmarkUserOptions$1;
|
||||
|
||||
export { LabelColor, ModuleGraphData, ProvidedContext, SerializedConfig, SerializedTestSpecification, UserConsoleLog, assertType, createExpect, globalExpect as expect, inject, vi, vitest };
|
||||
export type { ApiConfig, ArgumentsType, Arrayable, AssertType, Awaitable, BaseCoverageOptions, BenchmarkUserOptions, BrowserConfigOptions, BrowserScript, BrowserUI, BuiltinEnvironment, CSSModuleScopeStrategy, CollectLineNumbers, CollectLines, Constructable, Context, CoverageIstanbulOptions, CoverageOptions, CoverageProvider, CoverageProviderModule, CoverageReporter, CoverageV8Options, Custom, CustomProviderOptions, DepsOptimizationOptions, DoneCallback, Environment, EnvironmentOptions, EnvironmentReturn, File, HappyDOMOptions, InlineConfig, JSDOMOptions, MutableArray, Nullable, Pool, PoolOptions, ProjectConfig, RawErrsMap, ReportContext, Reporter, ResolvedConfig, ResolvedCoverageOptions, ResolvedTestEnvironment, RootAndTarget, RuntimeContext, SequenceHooks, SequenceSetupFiles, SerializableSpec, Suite, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, Test, TransformModePatterns, TransformResultWithSource, TscErrorInfo, TypecheckConfig, UserConfig, UserWorkspaceConfig, Vitest, VitestEnvironment, VitestRunMode, VitestUtils, VmEnvironmentReturn, WebSocketEvents, WebSocketHandlers, WebSocketRPC, WorkerContext, WorkerRPC };
|
||||
18
node_modules/vitest/dist/index.js
generated
vendored
Normal file
18
node_modules/vitest/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
export { c as createExpect, a as expect, i as inject, v as vi, b as vitest } from './chunks/vi.bdSIJ99Y.js';
|
||||
export { b as bench } from './chunks/benchmark.CYdenmiT.js';
|
||||
export { a as assertType } from './chunks/index.CdQS2e2Q.js';
|
||||
export { expectTypeOf } from 'expect-type';
|
||||
export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
||||
import * as chai from 'chai';
|
||||
export { chai };
|
||||
export { assert, should } from 'chai';
|
||||
import '@vitest/expect';
|
||||
import '@vitest/runner/utils';
|
||||
import './chunks/utils.XdZDrNZV.js';
|
||||
import '@vitest/utils';
|
||||
import './chunks/_commonjsHelpers.BFTU3MAI.js';
|
||||
import '@vitest/snapshot';
|
||||
import '@vitest/utils/error';
|
||||
import '@vitest/spy';
|
||||
import '@vitest/utils/source-map';
|
||||
import './chunks/date.Bq6ZW5rf.js';
|
||||
1
node_modules/vitest/dist/mocker.d.ts
generated
vendored
Normal file
1
node_modules/vitest/dist/mocker.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from '@vitest/mocker';
|
||||
1
node_modules/vitest/dist/mocker.js
generated
vendored
Normal file
1
node_modules/vitest/dist/mocker.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from '@vitest/mocker';
|
||||
158
node_modules/vitest/dist/node.d.ts
generated
vendored
Normal file
158
node_modules/vitest/dist/node.d.ts
generated
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
import { z as ResolvedConfig, y as UserConfig, v as VitestRunMode, H as VitestOptions, V as Vitest, A as ApiConfig, L as Logger, T as TestProject, J as TestSequencer, K as TestSpecification, M as TestModule, N as ModuleDiagnostic } from './chunks/reporters.d.BuRON0I0.js';
|
||||
export { B as BaseCoverageOptions, F as BenchmarkUserOptions, ag as BrowserBuiltinProvider, ah as BrowserCommand, ai as BrowserCommandContext, q as BrowserConfigOptions, aj as BrowserInstanceOption, ak as BrowserModuleMocker, al as BrowserOrchestrator, am as BrowserProvider, an as BrowserProviderInitializationOptions, ao as BrowserProviderModule, ap as BrowserProviderOptions, p as BrowserScript, aq as BrowserServerState, ar as BrowserServerStateSession, r as BuiltinEnvironment, as as CDPSession, u as CSSModuleScopeStrategy, m as CoverageIstanbulOptions, l as CoverageOptions, h as CoverageProvider, i as CoverageProviderModule, j as CoverageReporter, c as CoverageV8Options, n as CustomProviderOptions, D as DepsOptimizationOptions, a0 as HTMLOptions, I as InlineConfig, a2 as JUnitOptions, a1 as JsonOptions, O as OnServerRestartHandler, Q as OnTestsRerunHandler, at as ParentProjectBrowser, P as Pool, t as PoolOptions, Y as ProcessPool, au as ProjectBrowser, E as ProjectConfig, a as ReportContext, aA as ReportedHookContext, o as Reporter, ax as ResolveSnapshotPathHandler, ay as ResolveSnapshotPathHandlerContext, av as ResolvedBrowserOptions, R as ResolvedCoverageOptions, aw as ResolvedProjectConfig, $ as SerializedTestProject, a3 as TaskOptions, a4 as TestCase, a5 as TestCollection, a6 as TestDiagnostic, a7 as TestModuleState, a8 as TestResult, a9 as TestResultFailed, aa as TestResultPassed, ab as TestResultSkipped, aB as TestRunEndReason, az as TestRunResult, af as TestSequencerConstructor, ac as TestState, ad as TestSuite, ae as TestSuiteState, w as TransformModePatterns, x as TypecheckConfig, U as UserWorkspaceConfig, s as VitestEnvironment, X as VitestPackageInstaller, g as WatcherTriggerPattern, Z as WorkspaceSpec, _ as getFilePoolName } from './chunks/reporters.d.BuRON0I0.js';
|
||||
import * as vite from 'vite';
|
||||
import { InlineConfig, UserConfig as UserConfig$1, Plugin, ResolvedConfig as ResolvedConfig$1, LogLevel, LoggerOptions, Logger as Logger$1 } from 'vite';
|
||||
export { vite as Vite };
|
||||
export { esbuildVersion, isCSSRequest, isFileServingAllowed, parseAst, parseAstAsync, rollupVersion, version as viteVersion } from 'vite';
|
||||
import { IncomingMessage } from 'node:http';
|
||||
import { R as RuntimeRPC } from './chunks/worker.d.CUgIPz9V.js';
|
||||
export { T as TestExecutionType } from './chunks/worker.d.CUgIPz9V.js';
|
||||
import { Writable } from 'node:stream';
|
||||
export { V as VitestPluginContext } from './chunks/vite.d.BnOPPc46.js';
|
||||
export { W as WorkerContext } from './chunks/worker.d.uzWsCv9X.js';
|
||||
export { C as TypeCheckCollectLineNumbers, a as TypeCheckCollectLines, c as TypeCheckContext, T as TypeCheckErrorInfo, R as TypeCheckRawErrorsMap, b as TypeCheckRootAndTarget } from './chunks/global.d.MAmajcmJ.js';
|
||||
import { Debugger } from 'debug';
|
||||
export { Task as RunnerTask, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
|
||||
export { f as EnvironmentOptions, H as HappyDOMOptions, J as JSDOMOptions } from './chunks/environment.d.cL3nLXbE.js';
|
||||
export { SerializedError } from '@vitest/utils';
|
||||
export { b as RuntimeConfig } from './chunks/config.d.BKdhh7Zx.js';
|
||||
export { generateFileHash } from '@vitest/runner/utils';
|
||||
import 'node:console';
|
||||
import '@vitest/mocker';
|
||||
import '@vitest/utils/source-map';
|
||||
import '@vitest/pretty-format';
|
||||
import '@vitest/snapshot';
|
||||
import '@vitest/utils/diff';
|
||||
import 'vite-node';
|
||||
import 'chai';
|
||||
import './chunks/benchmark.d.BwvBVTda.js';
|
||||
import 'tinybench';
|
||||
import './chunks/coverage.d.S9RMNXIe.js';
|
||||
import 'vite-node/client';
|
||||
import '@vitest/snapshot/manager';
|
||||
import 'node:fs';
|
||||
import 'node:worker_threads';
|
||||
import '@vitest/expect';
|
||||
import 'vitest/optional-types.js';
|
||||
import '@vitest/snapshot/environment';
|
||||
|
||||
declare function isValidApiRequest(config: ResolvedConfig, req: IncomingMessage): boolean;
|
||||
|
||||
interface CliOptions extends UserConfig {
|
||||
/**
|
||||
* Override the watch mode
|
||||
*/
|
||||
run?: boolean;
|
||||
/**
|
||||
* Removes colors from the console output
|
||||
*/
|
||||
color?: boolean;
|
||||
/**
|
||||
* Output collected tests as JSON or to a file
|
||||
*/
|
||||
json?: string | boolean;
|
||||
/**
|
||||
* Output collected test files only
|
||||
*/
|
||||
filesOnly?: boolean;
|
||||
/**
|
||||
* Override vite config's configLoader from cli.
|
||||
* Use `bundle` to bundle the config with esbuild or `runner` (experimental) to process it on the fly (default: `bundle`).
|
||||
* This is only available with **vite version 6.1.0** and above.
|
||||
* @experimental
|
||||
*/
|
||||
configLoader?: InlineConfig extends {
|
||||
configLoader?: infer T
|
||||
} ? T : never;
|
||||
}
|
||||
/**
|
||||
* Start Vitest programmatically
|
||||
*
|
||||
* Returns a Vitest instance if initialized successfully.
|
||||
*/
|
||||
declare function startVitest(mode: VitestRunMode, cliFilters?: string[], options?: CliOptions, viteOverrides?: UserConfig$1, vitestOptions?: VitestOptions): Promise<Vitest>;
|
||||
|
||||
interface CliParseOptions {
|
||||
allowUnknownOptions?: boolean;
|
||||
}
|
||||
declare function parseCLI(argv: string | string[], config?: CliParseOptions): {
|
||||
filter: string[]
|
||||
options: CliOptions
|
||||
};
|
||||
|
||||
declare function resolveApiServerConfig<Options extends ApiConfig & UserConfig>(options: Options, defaultPort: number, parentApi?: ApiConfig, logger?: Logger): ApiConfig | undefined;
|
||||
|
||||
declare function createVitest(mode: VitestRunMode, options: CliOptions, viteOverrides?: UserConfig$1, vitestOptions?: VitestOptions): Promise<Vitest>;
|
||||
|
||||
declare class FilesNotFoundError extends Error {
|
||||
code: string;
|
||||
constructor(mode: "test" | "benchmark");
|
||||
}
|
||||
declare class GitNotFoundError extends Error {
|
||||
code: string;
|
||||
constructor();
|
||||
}
|
||||
|
||||
/** @deprecated use `TestProject` instead */
|
||||
type GlobalSetupContext = TestProject;
|
||||
|
||||
declare function VitestPlugin(options?: UserConfig, vitest?: Vitest): Promise<Plugin[]>;
|
||||
|
||||
// this is only exported as a public function and not used inside vitest
|
||||
declare function resolveConfig(options?: UserConfig, viteOverrides?: UserConfig$1): Promise<{
|
||||
vitestConfig: ResolvedConfig
|
||||
viteConfig: ResolvedConfig$1
|
||||
}>;
|
||||
|
||||
declare function resolveFsAllow(projectRoot: string, rootConfigFile: string | false | undefined): string[];
|
||||
|
||||
interface MethodsOptions {
|
||||
cacheFs?: boolean;
|
||||
// do not report files
|
||||
collect?: boolean;
|
||||
}
|
||||
declare function createMethodsRPC(project: TestProject, options?: MethodsOptions): RuntimeRPC;
|
||||
|
||||
declare class BaseSequencer implements TestSequencer {
|
||||
protected ctx: Vitest;
|
||||
constructor(ctx: Vitest);
|
||||
// async so it can be extended by other sequelizers
|
||||
shard(files: TestSpecification[]): Promise<TestSpecification[]>;
|
||||
// async so it can be extended by other sequelizers
|
||||
sort(files: TestSpecification[]): Promise<TestSpecification[]>;
|
||||
}
|
||||
|
||||
declare function registerConsoleShortcuts(ctx: Vitest, stdin: NodeJS.ReadStream | undefined, stdout: NodeJS.WriteStream | Writable): () => void;
|
||||
|
||||
// This is copy-pasted and needs to be synced from time to time. Ideally, Vite's `createLogger` should accept a custom `console`
|
||||
// https://github.com/vitejs/vite/blob/main/packages/vite/src/node/logger.ts?rgh-link-date=2024-10-16T23%3A29%3A19Z
|
||||
// When Vitest supports only Vite 6 and above, we can use Vite's `createLogger({ console })`
|
||||
// https://github.com/vitejs/vite/pull/18379
|
||||
declare function createViteLogger(console: Logger, level?: LogLevel, options?: LoggerOptions): Logger$1;
|
||||
|
||||
declare const rootDir: string;
|
||||
declare const distDir: string;
|
||||
|
||||
declare function createDebugger(namespace: `vitest:${string}`): Debugger | undefined;
|
||||
|
||||
declare const version: string;
|
||||
|
||||
/** @deprecated use `createViteServer` instead */
|
||||
declare const createServer: typeof vite.createServer;
|
||||
declare const createViteServer: typeof vite.createServer;
|
||||
|
||||
/**
|
||||
* @deprecated Use `TestModule` instead
|
||||
*/
|
||||
declare const TestFile: typeof TestModule;
|
||||
|
||||
/**
|
||||
* @deprecated Use `ModuleDiagnostic` instead
|
||||
*/
|
||||
type FileDiagnostic = ModuleDiagnostic;
|
||||
|
||||
// rolldownVersion is exported only by rolldown-vite
|
||||
declare const rolldownVersion: string | undefined;
|
||||
|
||||
export { ApiConfig, BaseSequencer, GitNotFoundError, ModuleDiagnostic, ResolvedConfig, TestFile, TestModule, TestProject, TestSequencer, TestSpecification, FilesNotFoundError as TestsNotFoundError, UserConfig, Vitest, VitestOptions, VitestPlugin, VitestRunMode, TestProject as WorkspaceProject, createDebugger, createMethodsRPC, createServer, createViteLogger, createViteServer, createVitest, distDir, isValidApiRequest, parseCLI, registerConsoleShortcuts, resolveApiServerConfig, resolveConfig, resolveFsAllow, rolldownVersion, rootDir, startVitest, version };
|
||||
export type { CliParseOptions, FileDiagnostic, GlobalSetupContext };
|
||||
105
node_modules/vitest/dist/node.js
generated
vendored
Normal file
105
node_modules/vitest/dist/node.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
import * as vite from 'vite';
|
||||
import { resolveConfig as resolveConfig$1, mergeConfig } from 'vite';
|
||||
export { esbuildVersion, isCSSRequest, isFileServingAllowed, parseAst, parseAstAsync, rollupVersion, version as viteVersion } from 'vite';
|
||||
import { V as Vitest, a as VitestPlugin, T as TestModule } from './chunks/cli-api.DWGBtMmz.js';
|
||||
export { G as GitNotFoundError, F as TestsNotFoundError, b as VitestPackageInstaller, e as createViteLogger, c as createVitest, i as isValidApiRequest, d as registerConsoleShortcuts, r as resolveFsAllow, s as startVitest } from './chunks/cli-api.DWGBtMmz.js';
|
||||
export { p as parseCLI } from './chunks/cac.0BJqEUeA.js';
|
||||
import { r as resolveConfig$2 } from './chunks/coverage.DfSpMS-b.js';
|
||||
export { b as BaseSequencer, c as createMethodsRPC, g as getFilePoolName, a as resolveApiServerConfig } from './chunks/coverage.DfSpMS-b.js';
|
||||
import { slash, deepClone } from '@vitest/utils';
|
||||
import { f as findUp } from './chunks/index.X0nbfr6-.js';
|
||||
import { resolve } from 'pathe';
|
||||
import { c as configFiles } from './chunks/constants.DnKduX2e.js';
|
||||
export { distDir, rootDir } from './path.js';
|
||||
import createDebug from 'debug';
|
||||
export { generateFileHash } from '@vitest/runner/utils';
|
||||
import 'node:fs';
|
||||
import './chunks/coverage.DVF1vEu8.js';
|
||||
import 'node:path';
|
||||
import '@vitest/snapshot/manager';
|
||||
import 'vite-node/client';
|
||||
import 'vite-node/server';
|
||||
import './chunks/index.B521nVV-.js';
|
||||
import './chunks/index.VByaPkjc.js';
|
||||
import 'node:perf_hooks';
|
||||
import '@vitest/utils/source-map';
|
||||
import 'tinyrainbow';
|
||||
import './chunks/env.D4Lgay0q.js';
|
||||
import 'std-env';
|
||||
import './chunks/typechecker.DRKU1-1g.js';
|
||||
import 'node:os';
|
||||
import 'tinyexec';
|
||||
import 'node:util';
|
||||
import 'node:fs/promises';
|
||||
import 'node:console';
|
||||
import 'node:stream';
|
||||
import 'node:module';
|
||||
import 'events';
|
||||
import 'https';
|
||||
import 'http';
|
||||
import 'net';
|
||||
import 'tls';
|
||||
import 'crypto';
|
||||
import 'stream';
|
||||
import 'url';
|
||||
import 'zlib';
|
||||
import 'buffer';
|
||||
import './chunks/_commonjsHelpers.BFTU3MAI.js';
|
||||
import 'node:crypto';
|
||||
import 'node:url';
|
||||
import 'picomatch';
|
||||
import 'tinyglobby';
|
||||
import 'vite-node/utils';
|
||||
import '@vitest/mocker/node';
|
||||
import './chunks/defaults.B7q_naMc.js';
|
||||
import 'magic-string';
|
||||
import './chunks/index.BCWujgDG.js';
|
||||
import 'node:assert';
|
||||
import '@vitest/utils/error';
|
||||
import 'node:readline';
|
||||
import 'node:process';
|
||||
import 'node:v8';
|
||||
import 'node:tty';
|
||||
import 'node:events';
|
||||
import 'tinypool';
|
||||
import 'node:worker_threads';
|
||||
import 'readline';
|
||||
|
||||
// this is only exported as a public function and not used inside vitest
|
||||
async function resolveConfig(options = {}, viteOverrides = {}) {
|
||||
const root = slash(resolve(options.root || process.cwd()));
|
||||
const configPath = options.config === false ? false : options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
|
||||
options.config = configPath;
|
||||
const vitest = new Vitest("test", deepClone(options));
|
||||
const config = await resolveConfig$1(mergeConfig({
|
||||
configFile: configPath,
|
||||
mode: options.mode || "test",
|
||||
plugins: [await VitestPlugin(options, vitest)]
|
||||
}, mergeConfig(viteOverrides, { root: options.root })), "serve");
|
||||
// Reflect just to avoid type error
|
||||
const updatedOptions = Reflect.get(config, "_vitest");
|
||||
const vitestConfig = resolveConfig$2(vitest, updatedOptions, config);
|
||||
await vitest.close();
|
||||
return {
|
||||
viteConfig: config,
|
||||
vitestConfig
|
||||
};
|
||||
}
|
||||
|
||||
function createDebugger(namespace) {
|
||||
const debug = createDebug(namespace);
|
||||
if (debug.enabled) return debug;
|
||||
}
|
||||
|
||||
const version = Vitest.version;
|
||||
/** @deprecated use `createViteServer` instead */
|
||||
const createServer = vite.createServer;
|
||||
const createViteServer = vite.createServer;
|
||||
/**
|
||||
* @deprecated Use `TestModule` instead
|
||||
*/
|
||||
const TestFile = TestModule;
|
||||
// rolldownVersion is exported only by rolldown-vite
|
||||
const rolldownVersion = vite.rolldownVersion;
|
||||
|
||||
export { TestFile, VitestPlugin, createDebugger, createServer, createViteServer, resolveConfig, rolldownVersion, version };
|
||||
7
node_modules/vitest/dist/path.js
generated
vendored
Normal file
7
node_modules/vitest/dist/path.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { resolve } from 'node:path';
|
||||
import url from 'node:url';
|
||||
|
||||
const rootDir = resolve(url.fileURLToPath(import.meta.url), "../../");
|
||||
const distDir = resolve(url.fileURLToPath(import.meta.url), "../../dist");
|
||||
|
||||
export { distDir, rootDir };
|
||||
25
node_modules/vitest/dist/reporters.d.ts
generated
vendored
Normal file
25
node_modules/vitest/dist/reporters.d.ts
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
export { aQ as BaseReporter, aC as BasicReporter, aR as BenchmarkBuiltinReporters, aD as BenchmarkReporter, aE as BenchmarkReportsMap, aS as BuiltinReporterOptions, aT as BuiltinReporters, aF as DefaultReporter, aG as DotReporter, aH as GithubActionsReporter, aI as HangingProcessReporter, aK as JUnitReporter, aU as JsonAssertionResult, aJ as JsonReporter, aV as JsonTestResult, aW as JsonTestResults, aA as ReportedHookContext, o as Reporter, aL as ReportersMap, aM as TapFlatReporter, aN as TapReporter, aB as TestRunEndReason, aO as VerboseBenchmarkReporter, aP as VerboseReporter } from './chunks/reporters.d.BuRON0I0.js';
|
||||
import '@vitest/runner';
|
||||
import './chunks/environment.d.cL3nLXbE.js';
|
||||
import 'vitest/optional-types.js';
|
||||
import '@vitest/utils';
|
||||
import 'node:stream';
|
||||
import 'vite';
|
||||
import 'node:console';
|
||||
import '@vitest/mocker';
|
||||
import '@vitest/utils/source-map';
|
||||
import './chunks/worker.d.CUgIPz9V.js';
|
||||
import 'vite-node';
|
||||
import './chunks/config.d.BKdhh7Zx.js';
|
||||
import '@vitest/pretty-format';
|
||||
import '@vitest/snapshot';
|
||||
import '@vitest/snapshot/environment';
|
||||
import '@vitest/utils/diff';
|
||||
import 'chai';
|
||||
import './chunks/benchmark.d.BwvBVTda.js';
|
||||
import '@vitest/runner/utils';
|
||||
import 'tinybench';
|
||||
import './chunks/coverage.d.S9RMNXIe.js';
|
||||
import 'vite-node/client';
|
||||
import '@vitest/snapshot/manager';
|
||||
import 'node:fs';
|
||||
23
node_modules/vitest/dist/reporters.js
generated
vendored
Normal file
23
node_modules/vitest/dist/reporters.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
export { B as BasicReporter, D as DefaultReporter, a as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, b as JUnitReporter, J as JsonReporter, R as ReportersMap, T as TapFlatReporter, c as TapReporter, V as VerboseReporter } from './chunks/index.VByaPkjc.js';
|
||||
export { B as BenchmarkReporter, a as BenchmarkReportsMap, V as VerboseBenchmarkReporter } from './chunks/index.BCWujgDG.js';
|
||||
import 'node:perf_hooks';
|
||||
import '@vitest/runner/utils';
|
||||
import '@vitest/utils';
|
||||
import '@vitest/utils/source-map';
|
||||
import 'pathe';
|
||||
import 'tinyrainbow';
|
||||
import './chunks/env.D4Lgay0q.js';
|
||||
import 'std-env';
|
||||
import './chunks/typechecker.DRKU1-1g.js';
|
||||
import 'node:os';
|
||||
import 'tinyexec';
|
||||
import './path.js';
|
||||
import 'node:path';
|
||||
import 'node:url';
|
||||
import 'vite';
|
||||
import 'node:util';
|
||||
import 'node:fs';
|
||||
import 'node:fs/promises';
|
||||
import 'node:console';
|
||||
import 'node:stream';
|
||||
import 'node:module';
|
||||
46
node_modules/vitest/dist/runners.d.ts
generated
vendored
Normal file
46
node_modules/vitest/dist/runners.d.ts
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import * as tinybench from 'tinybench';
|
||||
import { VitestRunner, VitestRunnerImportSource, Suite, File, Task, CancelReason, Test, TestContext, ImportDuration } from '@vitest/runner';
|
||||
export { VitestRunner } from '@vitest/runner';
|
||||
import { a as SerializedConfig } from './chunks/config.d.BKdhh7Zx.js';
|
||||
import '@vitest/pretty-format';
|
||||
import '@vitest/snapshot';
|
||||
import '@vitest/snapshot/environment';
|
||||
import '@vitest/utils/diff';
|
||||
|
||||
declare class NodeBenchmarkRunner implements VitestRunner {
|
||||
config: SerializedConfig;
|
||||
private __vitest_executor;
|
||||
constructor(config: SerializedConfig);
|
||||
importTinybench(): Promise<typeof tinybench>;
|
||||
importFile(filepath: string, source: VitestRunnerImportSource): unknown;
|
||||
runSuite(suite: Suite): Promise<void>;
|
||||
runTask(): Promise<void>;
|
||||
}
|
||||
|
||||
declare class VitestTestRunner implements VitestRunner {
|
||||
config: SerializedConfig;
|
||||
private snapshotClient;
|
||||
private workerState;
|
||||
private __vitest_executor;
|
||||
private cancelRun;
|
||||
private assertionsErrors;
|
||||
pool: string;
|
||||
constructor(config: SerializedConfig);
|
||||
importFile(filepath: string, source: VitestRunnerImportSource): unknown;
|
||||
onCollectStart(file: File): void;
|
||||
onCleanupWorkerContext(listener: () => unknown): void;
|
||||
onAfterRunFiles(): void;
|
||||
getWorkerContext(): Record<string, unknown>;
|
||||
onAfterRunSuite(suite: Suite): Promise<void>;
|
||||
onAfterRunTask(test: Task): void;
|
||||
cancel(_reason: CancelReason): void;
|
||||
injectValue(key: string): any;
|
||||
onBeforeRunTask(test: Task): Promise<void>;
|
||||
onBeforeRunSuite(suite: Suite): Promise<void>;
|
||||
onBeforeTryTask(test: Task): void;
|
||||
onAfterTryTask(test: Test): void;
|
||||
extendTaskContext(context: TestContext): TestContext;
|
||||
getImportDurations(): Record<string, ImportDuration>;
|
||||
}
|
||||
|
||||
export { NodeBenchmarkRunner, VitestTestRunner };
|
||||
235
node_modules/vitest/dist/runners.js
generated
vendored
Normal file
235
node_modules/vitest/dist/runners.js
generated
vendored
Normal file
@@ -0,0 +1,235 @@
|
||||
import { updateTask } from '@vitest/runner';
|
||||
import { createDefer, getSafeTimers } from '@vitest/utils';
|
||||
import { a as getBenchOptions, g as getBenchFn } from './chunks/benchmark.CYdenmiT.js';
|
||||
import { g as getWorkerState } from './chunks/utils.XdZDrNZV.js';
|
||||
import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
|
||||
import { getTests, getNames, getTestName } from '@vitest/runner/utils';
|
||||
import { normalize } from 'pathe';
|
||||
import { g as getSnapshotClient, i as inject, c as createExpect, v as vi } from './chunks/vi.bdSIJ99Y.js';
|
||||
import { r as rpc } from './chunks/rpc.-pEldfrD.js';
|
||||
import 'chai';
|
||||
import './chunks/_commonjsHelpers.BFTU3MAI.js';
|
||||
import '@vitest/snapshot';
|
||||
import '@vitest/utils/error';
|
||||
import '@vitest/spy';
|
||||
import '@vitest/utils/source-map';
|
||||
import './chunks/date.Bq6ZW5rf.js';
|
||||
import './chunks/index.B521nVV-.js';
|
||||
|
||||
function createBenchmarkResult(name) {
|
||||
return {
|
||||
name,
|
||||
rank: 0,
|
||||
rme: 0,
|
||||
samples: []
|
||||
};
|
||||
}
|
||||
const benchmarkTasks = /* @__PURE__ */ new WeakMap();
|
||||
async function runBenchmarkSuite(suite, runner) {
|
||||
const { Task, Bench } = await runner.importTinybench();
|
||||
const start = performance.now();
|
||||
const benchmarkGroup = [];
|
||||
const benchmarkSuiteGroup = [];
|
||||
for (const task of suite.tasks) {
|
||||
if (task.mode !== "run" && task.mode !== "queued") continue;
|
||||
if (task.meta?.benchmark) benchmarkGroup.push(task);
|
||||
else if (task.type === "suite") benchmarkSuiteGroup.push(task);
|
||||
}
|
||||
// run sub suites sequentially
|
||||
for (const subSuite of benchmarkSuiteGroup) await runBenchmarkSuite(subSuite, runner);
|
||||
if (benchmarkGroup.length) {
|
||||
const defer = createDefer();
|
||||
suite.result = {
|
||||
state: "run",
|
||||
startTime: start,
|
||||
benchmark: createBenchmarkResult(suite.name)
|
||||
};
|
||||
updateTask$1("suite-prepare", suite);
|
||||
const addBenchTaskListener = (task, benchmark) => {
|
||||
task.addEventListener("complete", (e) => {
|
||||
const task = e.task;
|
||||
const taskRes = task.result;
|
||||
const result = benchmark.result.benchmark;
|
||||
benchmark.result.state = "pass";
|
||||
Object.assign(result, taskRes);
|
||||
// compute extra stats and free raw samples as early as possible
|
||||
const samples = result.samples;
|
||||
result.sampleCount = samples.length;
|
||||
result.median = samples.length % 2 ? samples[Math.floor(samples.length / 2)] : (samples[samples.length / 2] + samples[samples.length / 2 - 1]) / 2;
|
||||
if (!runner.config.benchmark?.includeSamples) result.samples.length = 0;
|
||||
updateTask$1("test-finished", benchmark);
|
||||
}, { once: true });
|
||||
task.addEventListener("error", (e) => {
|
||||
const task = e.task;
|
||||
defer.reject(benchmark ? task.result.error : e);
|
||||
}, { once: true });
|
||||
};
|
||||
benchmarkGroup.forEach((benchmark) => {
|
||||
const options = getBenchOptions(benchmark);
|
||||
const benchmarkInstance = new Bench(options);
|
||||
const benchmarkFn = getBenchFn(benchmark);
|
||||
benchmark.result = {
|
||||
state: "run",
|
||||
startTime: start,
|
||||
benchmark: createBenchmarkResult(benchmark.name)
|
||||
};
|
||||
const task = new Task(benchmarkInstance, benchmark.name, benchmarkFn);
|
||||
benchmarkTasks.set(benchmark, task);
|
||||
addBenchTaskListener(task, benchmark);
|
||||
});
|
||||
const { setTimeout } = getSafeTimers();
|
||||
const tasks = [];
|
||||
for (const benchmark of benchmarkGroup) {
|
||||
const task = benchmarkTasks.get(benchmark);
|
||||
updateTask$1("test-prepare", benchmark);
|
||||
await task.warmup();
|
||||
tasks.push([await new Promise((resolve) => setTimeout(async () => {
|
||||
resolve(await task.run());
|
||||
})), benchmark]);
|
||||
}
|
||||
suite.result.duration = performance.now() - start;
|
||||
suite.result.state = "pass";
|
||||
updateTask$1("suite-finished", suite);
|
||||
defer.resolve(null);
|
||||
await defer;
|
||||
}
|
||||
function updateTask$1(event, task) {
|
||||
updateTask(event, task, runner);
|
||||
}
|
||||
}
|
||||
class NodeBenchmarkRunner {
|
||||
__vitest_executor;
|
||||
constructor(config) {
|
||||
this.config = config;
|
||||
}
|
||||
async importTinybench() {
|
||||
return await import('tinybench');
|
||||
}
|
||||
importFile(filepath, source) {
|
||||
if (source === "setup") getWorkerState().moduleCache.delete(filepath);
|
||||
return this.__vitest_executor.executeId(filepath);
|
||||
}
|
||||
async runSuite(suite) {
|
||||
await runBenchmarkSuite(suite, this);
|
||||
}
|
||||
async runTask() {
|
||||
throw new Error("`test()` and `it()` is only available in test mode.");
|
||||
}
|
||||
}
|
||||
|
||||
// worker context is shared between all tests
|
||||
const workerContext = Object.create(null);
|
||||
class VitestTestRunner {
|
||||
snapshotClient = getSnapshotClient();
|
||||
workerState = getWorkerState();
|
||||
__vitest_executor;
|
||||
cancelRun = false;
|
||||
assertionsErrors = /* @__PURE__ */ new WeakMap();
|
||||
pool = this.workerState.ctx.pool;
|
||||
constructor(config) {
|
||||
this.config = config;
|
||||
}
|
||||
importFile(filepath, source) {
|
||||
if (source === "setup") this.workerState.moduleCache.delete(filepath);
|
||||
return this.__vitest_executor.executeId(filepath);
|
||||
}
|
||||
onCollectStart(file) {
|
||||
this.workerState.current = file;
|
||||
}
|
||||
onCleanupWorkerContext(listener) {
|
||||
this.workerState.onCleanup(listener);
|
||||
}
|
||||
onAfterRunFiles() {
|
||||
this.snapshotClient.clear();
|
||||
this.workerState.current = void 0;
|
||||
}
|
||||
getWorkerContext() {
|
||||
return workerContext;
|
||||
}
|
||||
async onAfterRunSuite(suite) {
|
||||
if (this.config.logHeapUsage && typeof process !== "undefined") suite.result.heap = process.memoryUsage().heapUsed;
|
||||
if (suite.mode !== "skip" && "filepath" in suite) {
|
||||
// mark snapshots in skipped tests as not obsolete
|
||||
for (const test of getTests(suite)) if (test.mode === "skip") {
|
||||
const name = getNames(test).slice(1).join(" > ");
|
||||
this.snapshotClient.skipTest(suite.file.filepath, name);
|
||||
}
|
||||
const result = await this.snapshotClient.finish(suite.file.filepath);
|
||||
await rpc().snapshotSaved(result);
|
||||
}
|
||||
this.workerState.current = suite.suite || suite.file;
|
||||
}
|
||||
onAfterRunTask(test) {
|
||||
if (this.config.logHeapUsage && typeof process !== "undefined") test.result.heap = process.memoryUsage().heapUsed;
|
||||
this.workerState.current = test.suite || test.file;
|
||||
}
|
||||
cancel(_reason) {
|
||||
this.cancelRun = true;
|
||||
}
|
||||
injectValue(key) {
|
||||
// inject has a very limiting type controlled by ProvidedContext
|
||||
// some tests override it which causes the build to fail
|
||||
return inject(key);
|
||||
}
|
||||
async onBeforeRunTask(test) {
|
||||
if (this.cancelRun) test.mode = "skip";
|
||||
if (test.mode !== "run" && test.mode !== "queued") return;
|
||||
this.workerState.current = test;
|
||||
}
|
||||
async onBeforeRunSuite(suite) {
|
||||
if (this.cancelRun) suite.mode = "skip";
|
||||
// initialize snapshot state before running file suite
|
||||
if (suite.mode !== "skip" && "filepath" in suite) await this.snapshotClient.setup(suite.file.filepath, this.workerState.config.snapshotOptions);
|
||||
this.workerState.current = suite;
|
||||
}
|
||||
onBeforeTryTask(test) {
|
||||
clearModuleMocks(this.config);
|
||||
this.snapshotClient.clearTest(test.file.filepath, test.id);
|
||||
setState({
|
||||
assertionCalls: 0,
|
||||
isExpectingAssertions: false,
|
||||
isExpectingAssertionsError: null,
|
||||
expectedAssertionsNumber: null,
|
||||
expectedAssertionsNumberErrorGen: null,
|
||||
currentTestName: getTestName(test),
|
||||
snapshotState: this.snapshotClient.getSnapshotState(test.file.filepath)
|
||||
}, globalThis[GLOBAL_EXPECT]);
|
||||
}
|
||||
onAfterTryTask(test) {
|
||||
const { assertionCalls, expectedAssertionsNumber, expectedAssertionsNumberErrorGen, isExpectingAssertions, isExpectingAssertionsError } = test.context._local ? test.context.expect.getState() : getState(globalThis[GLOBAL_EXPECT]);
|
||||
if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber) throw expectedAssertionsNumberErrorGen();
|
||||
if (isExpectingAssertions === true && assertionCalls === 0) throw isExpectingAssertionsError;
|
||||
if (this.config.expect.requireAssertions && assertionCalls === 0) throw this.assertionsErrors.get(test);
|
||||
}
|
||||
extendTaskContext(context) {
|
||||
// create error during the test initialization so we have a nice stack trace
|
||||
if (this.config.expect.requireAssertions) this.assertionsErrors.set(context.task, new Error("expected any number of assertion, but got none"));
|
||||
let _expect;
|
||||
Object.defineProperty(context, "expect", { get() {
|
||||
if (!_expect) _expect = createExpect(context.task);
|
||||
return _expect;
|
||||
} });
|
||||
Object.defineProperty(context, "_local", { get() {
|
||||
return _expect != null;
|
||||
} });
|
||||
return context;
|
||||
}
|
||||
getImportDurations() {
|
||||
const entries = [...this.workerState.moduleExecutionInfo?.entries() ?? []];
|
||||
return Object.fromEntries(entries.map(([filepath, { duration, selfTime }]) => [normalize(filepath), {
|
||||
selfTime,
|
||||
totalTime: duration
|
||||
}]));
|
||||
}
|
||||
}
|
||||
function clearModuleMocks(config) {
|
||||
const { clearMocks, mockReset, restoreMocks, unstubEnvs, unstubGlobals } = config;
|
||||
// since each function calls another, we can just call one
|
||||
if (restoreMocks) vi.restoreAllMocks();
|
||||
else if (mockReset) vi.resetAllMocks();
|
||||
else if (clearMocks) vi.clearAllMocks();
|
||||
if (unstubEnvs) vi.unstubAllEnvs();
|
||||
if (unstubGlobals) vi.unstubAllGlobals();
|
||||
}
|
||||
|
||||
export { NodeBenchmarkRunner, VitestTestRunner };
|
||||
9
node_modules/vitest/dist/snapshot.d.ts
generated
vendored
Normal file
9
node_modules/vitest/dist/snapshot.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
|
||||
export { SnapshotEnvironment } from '@vitest/snapshot/environment';
|
||||
|
||||
declare class VitestNodeSnapshotEnvironment extends NodeSnapshotEnvironment {
|
||||
getHeader(): string;
|
||||
resolvePath(filepath: string): Promise<string>;
|
||||
}
|
||||
|
||||
export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment };
|
||||
4
node_modules/vitest/dist/snapshot.js
generated
vendored
Normal file
4
node_modules/vitest/dist/snapshot.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/node.fjCdwEIl.js';
|
||||
import '@vitest/snapshot/environment';
|
||||
import './chunks/utils.XdZDrNZV.js';
|
||||
import '@vitest/utils';
|
||||
1
node_modules/vitest/dist/spy.js
generated
vendored
Normal file
1
node_modules/vitest/dist/spy.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from '@vitest/spy';
|
||||
5
node_modules/vitest/dist/suite.d.ts
generated
vendored
Normal file
5
node_modules/vitest/dist/suite.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export { g as getBenchFn, a as getBenchOptions } from './chunks/suite.d.FvehnV49.js';
|
||||
export { VitestRunner, VitestRunnerConfig, createTaskCollector, getCurrentSuite, getCurrentTest, getFn, getHooks, setFn, setHooks } from '@vitest/runner';
|
||||
export { createChainable } from '@vitest/runner/utils';
|
||||
import './chunks/benchmark.d.BwvBVTda.js';
|
||||
import 'tinybench';
|
||||
5
node_modules/vitest/dist/suite.js
generated
vendored
Normal file
5
node_modules/vitest/dist/suite.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export { g as getBenchFn, a as getBenchOptions } from './chunks/benchmark.CYdenmiT.js';
|
||||
export { createTaskCollector, getCurrentSuite, getCurrentTest, getFn, getHooks, setFn, setHooks } from '@vitest/runner';
|
||||
export { createChainable } from '@vitest/runner/utils';
|
||||
import '@vitest/utils';
|
||||
import './chunks/utils.XdZDrNZV.js';
|
||||
124
node_modules/vitest/dist/worker.js
generated
vendored
Normal file
124
node_modules/vitest/dist/worker.js
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import { createStackString, parseStacktrace } from '@vitest/utils/source-map';
|
||||
import { workerId } from 'tinypool';
|
||||
import { ViteNodeRunner, ModuleCacheMap } from 'vite-node/client';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve, normalize } from 'pathe';
|
||||
import { e as environments } from './chunks/index.CmSc2RE5.js';
|
||||
import { s as setupInspect } from './chunks/inspector.C914Efll.js';
|
||||
import { c as createRuntimeRpc, a as rpcDone } from './chunks/rpc.-pEldfrD.js';
|
||||
import { i as isChildProcess, s as setProcessTitle } from './chunks/utils.XdZDrNZV.js';
|
||||
import { d as disposeInternalListeners } from './chunks/utils.CAioKnHs.js';
|
||||
import 'node:console';
|
||||
import 'node:module';
|
||||
import '@vitest/utils';
|
||||
import './chunks/index.B521nVV-.js';
|
||||
|
||||
function isBuiltinEnvironment(env) {
|
||||
return env in environments;
|
||||
}
|
||||
const _loaders = /* @__PURE__ */ new Map();
|
||||
async function createEnvironmentLoader(options) {
|
||||
if (!_loaders.has(options.root)) {
|
||||
const loader = new ViteNodeRunner(options);
|
||||
await loader.executeId("/@vite/env");
|
||||
_loaders.set(options.root, loader);
|
||||
}
|
||||
return _loaders.get(options.root);
|
||||
}
|
||||
async function loadEnvironment(ctx, rpc) {
|
||||
const name = ctx.environment.name;
|
||||
if (isBuiltinEnvironment(name)) return environments[name];
|
||||
const loader = await createEnvironmentLoader({
|
||||
root: ctx.config.root,
|
||||
fetchModule: async (id) => {
|
||||
const result = await rpc.fetch(id, "ssr");
|
||||
if (result.id) return { code: readFileSync(result.id, "utf-8") };
|
||||
return result;
|
||||
},
|
||||
resolveId: (id, importer) => rpc.resolveId(id, importer, "ssr")
|
||||
});
|
||||
const root = loader.root;
|
||||
const packageId = name[0] === "." || name[0] === "/" ? resolve(root, name) : (await rpc.resolveId(`vitest-environment-${name}`, void 0, "ssr"))?.id ?? resolve(root, name);
|
||||
const pkg = await loader.executeId(normalize(packageId));
|
||||
if (!pkg || !pkg.default || typeof pkg.default !== "object") throw new TypeError(`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "setup" or/and "setupVM" method.`);
|
||||
const environment = pkg.default;
|
||||
if (environment.transformMode !== "web" && environment.transformMode !== "ssr") throw new TypeError(`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "transformMode" method equal to "ssr" or "web".`);
|
||||
return environment;
|
||||
}
|
||||
|
||||
const listeners = /* @__PURE__ */ new Set();
|
||||
function addCleanupListener(listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
async function cleanup() {
|
||||
const promises = [...listeners].map((l) => l());
|
||||
await Promise.all(promises);
|
||||
}
|
||||
|
||||
if (isChildProcess()) {
|
||||
setProcessTitle(`vitest ${workerId}`);
|
||||
const isProfiling = process.execArgv.some((execArg) => execArg.startsWith("--prof") || execArg.startsWith("--cpu-prof") || execArg.startsWith("--heap-prof") || execArg.startsWith("--diagnostic-dir"));
|
||||
if (isProfiling)
|
||||
// Work-around for nodejs/node#55094
|
||||
process.on("SIGTERM", () => {
|
||||
process.exit();
|
||||
});
|
||||
}
|
||||
// this is what every pool executes when running tests
|
||||
async function execute(method, ctx) {
|
||||
disposeInternalListeners();
|
||||
const prepareStart = performance.now();
|
||||
const inspectorCleanup = setupInspect(ctx);
|
||||
process.env.VITEST_WORKER_ID = String(ctx.workerId);
|
||||
process.env.VITEST_POOL_ID = String(workerId);
|
||||
try {
|
||||
// worker is a filepath or URL to a file that exposes a default export with "getRpcOptions" and "runTests" methods
|
||||
if (ctx.worker[0] === ".") throw new Error(`Path to the test runner cannot be relative, received "${ctx.worker}"`);
|
||||
const file = ctx.worker.startsWith("file:") ? ctx.worker : pathToFileURL(ctx.worker).toString();
|
||||
const testRunnerModule = await import(file);
|
||||
if (!testRunnerModule.default || typeof testRunnerModule.default !== "object") throw new TypeError(`Test worker object should be exposed as a default export. Received "${typeof testRunnerModule.default}"`);
|
||||
const worker = testRunnerModule.default;
|
||||
if (!worker.getRpcOptions || typeof worker.getRpcOptions !== "function") throw new TypeError(`Test worker should expose "getRpcOptions" method. Received "${typeof worker.getRpcOptions}".`);
|
||||
// RPC is used to communicate between worker (be it a thread worker or child process or a custom implementation) and the main thread
|
||||
const { rpc, onCancel } = createRuntimeRpc(worker.getRpcOptions(ctx));
|
||||
const beforeEnvironmentTime = performance.now();
|
||||
const environment = await loadEnvironment(ctx, rpc);
|
||||
if (ctx.environment.transformMode) environment.transformMode = ctx.environment.transformMode;
|
||||
const state = {
|
||||
ctx,
|
||||
moduleCache: new ModuleCacheMap(),
|
||||
moduleExecutionInfo: /* @__PURE__ */ new Map(),
|
||||
config: ctx.config,
|
||||
onCancel,
|
||||
environment,
|
||||
durations: {
|
||||
environment: beforeEnvironmentTime,
|
||||
prepare: prepareStart
|
||||
},
|
||||
rpc,
|
||||
onCleanup: (listener) => addCleanupListener(listener),
|
||||
providedContext: ctx.providedContext,
|
||||
onFilterStackTrace(stack) {
|
||||
return createStackString(parseStacktrace(stack));
|
||||
}
|
||||
};
|
||||
const methodName = method === "collect" ? "collectTests" : "runTests";
|
||||
if (!worker[methodName] || typeof worker[methodName] !== "function") throw new TypeError(`Test worker should expose "runTests" method. Received "${typeof worker.runTests}".`);
|
||||
await worker[methodName](state);
|
||||
} finally {
|
||||
await rpcDone().catch(() => {});
|
||||
inspectorCleanup();
|
||||
}
|
||||
}
|
||||
function run(ctx) {
|
||||
return execute("run", ctx);
|
||||
}
|
||||
function collect(ctx) {
|
||||
return execute("collect", ctx);
|
||||
}
|
||||
async function teardown() {
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
export { collect, run, teardown };
|
||||
40
node_modules/vitest/dist/workers.d.ts
generated
vendored
Normal file
40
node_modules/vitest/dist/workers.d.ts
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
import { W as WorkerGlobalState, C as ContextRPC, B as BirpcOptions, R as RuntimeRPC } from './chunks/worker.d.CUgIPz9V.js';
|
||||
import { Awaitable } from '@vitest/utils';
|
||||
import * as v8 from 'v8';
|
||||
import { a as SerializedConfig } from './chunks/config.d.BKdhh7Zx.js';
|
||||
import { W as WorkerContext } from './chunks/worker.d.uzWsCv9X.js';
|
||||
import '@vitest/runner';
|
||||
import 'vite-node';
|
||||
import './chunks/environment.d.cL3nLXbE.js';
|
||||
import 'vitest/optional-types.js';
|
||||
import '@vitest/snapshot';
|
||||
import '@vitest/pretty-format';
|
||||
import '@vitest/snapshot/environment';
|
||||
import '@vitest/utils/diff';
|
||||
import 'node:worker_threads';
|
||||
|
||||
declare function provideWorkerState(context: any, state: WorkerGlobalState): WorkerGlobalState;
|
||||
|
||||
declare function run(ctx: ContextRPC): Promise<void>;
|
||||
declare function collect(ctx: ContextRPC): Promise<void>;
|
||||
|
||||
declare function runBaseTests(method: "run" | "collect", state: WorkerGlobalState): Promise<void>;
|
||||
|
||||
type WorkerRpcOptions = Pick<BirpcOptions<RuntimeRPC>, "on" | "post" | "serialize" | "deserialize">;
|
||||
interface VitestWorker {
|
||||
getRpcOptions: (ctx: ContextRPC) => WorkerRpcOptions;
|
||||
runTests: (state: WorkerGlobalState) => Awaitable<unknown>;
|
||||
collectTests: (state: WorkerGlobalState) => Awaitable<unknown>;
|
||||
}
|
||||
|
||||
declare function createThreadsRpcOptions({ port }: WorkerContext): WorkerRpcOptions;
|
||||
declare function createForksRpcOptions(nodeV8: typeof v8): WorkerRpcOptions;
|
||||
/**
|
||||
* Reverts the wrapping done by `utils/config-helpers.ts`'s `wrapSerializableConfig`
|
||||
*/
|
||||
declare function unwrapSerializableConfig(config: SerializedConfig): SerializedConfig;
|
||||
|
||||
declare function runVmTests(method: "run" | "collect", state: WorkerGlobalState): Promise<void>;
|
||||
|
||||
export { collect as collectVitestWorkerTests, createForksRpcOptions, createThreadsRpcOptions, provideWorkerState, runBaseTests, run as runVitestWorker, runVmTests, unwrapSerializableConfig };
|
||||
export type { VitestWorker, WorkerRpcOptions };
|
||||
30
node_modules/vitest/dist/workers.js
generated
vendored
Normal file
30
node_modules/vitest/dist/workers.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
export { p as provideWorkerState } from './chunks/utils.XdZDrNZV.js';
|
||||
export { collect as collectVitestWorkerTests, run as runVitestWorker } from './worker.js';
|
||||
export { r as runBaseTests } from './chunks/base.DfmxU-tU.js';
|
||||
export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSerializableConfig } from './chunks/utils.CAioKnHs.js';
|
||||
export { r as runVmTests } from './chunks/vm.BThCzidc.js';
|
||||
import '@vitest/utils';
|
||||
import 'node:url';
|
||||
import '@vitest/utils/source-map';
|
||||
import 'tinypool';
|
||||
import 'vite-node/client';
|
||||
import 'node:fs';
|
||||
import 'pathe';
|
||||
import './chunks/index.CmSc2RE5.js';
|
||||
import 'node:console';
|
||||
import './chunks/inspector.C914Efll.js';
|
||||
import 'node:module';
|
||||
import './chunks/rpc.-pEldfrD.js';
|
||||
import './chunks/index.B521nVV-.js';
|
||||
import './chunks/execute.B7h3T_Hc.js';
|
||||
import 'node:vm';
|
||||
import '@vitest/utils/error';
|
||||
import 'vite-node/utils';
|
||||
import './path.js';
|
||||
import 'node:path';
|
||||
import '@vitest/mocker';
|
||||
import './chunks/console.CtFJOzRO.js';
|
||||
import 'node:stream';
|
||||
import 'tinyrainbow';
|
||||
import './chunks/date.Bq6ZW5rf.js';
|
||||
import 'vite-node/constants';
|
||||
43
node_modules/vitest/dist/workers/forks.js
generated
vendored
Normal file
43
node_modules/vitest/dist/workers/forks.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
import v8 from 'node:v8';
|
||||
import { r as runBaseTests } from '../chunks/base.DfmxU-tU.js';
|
||||
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.CAioKnHs.js';
|
||||
import 'vite-node/client';
|
||||
import '../chunks/execute.B7h3T_Hc.js';
|
||||
import 'node:fs';
|
||||
import 'node:url';
|
||||
import 'node:vm';
|
||||
import '@vitest/utils/error';
|
||||
import 'pathe';
|
||||
import 'vite-node/utils';
|
||||
import '../path.js';
|
||||
import 'node:path';
|
||||
import '@vitest/mocker';
|
||||
import 'node:module';
|
||||
import '@vitest/utils';
|
||||
import '../chunks/utils.XdZDrNZV.js';
|
||||
|
||||
class ForksBaseWorker {
|
||||
getRpcOptions() {
|
||||
return createForksRpcOptions(v8);
|
||||
}
|
||||
async executeTests(method, state) {
|
||||
// TODO: don't rely on reassigning process.exit
|
||||
// https://github.com/vitest-dev/vitest/pull/4441#discussion_r1443771486
|
||||
const exit = process.exit;
|
||||
state.ctx.config = unwrapSerializableConfig(state.ctx.config);
|
||||
try {
|
||||
await runBaseTests(method, state);
|
||||
} finally {
|
||||
process.exit = exit;
|
||||
}
|
||||
}
|
||||
runTests(state) {
|
||||
return this.executeTests("run", state);
|
||||
}
|
||||
collectTests(state) {
|
||||
return this.executeTests("collect", state);
|
||||
}
|
||||
}
|
||||
const worker = new ForksBaseWorker();
|
||||
|
||||
export { worker as default };
|
||||
90
node_modules/vitest/dist/workers/runVmTests.js
generated
vendored
Normal file
90
node_modules/vitest/dist/workers/runVmTests.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
import { createRequire } from 'node:module';
|
||||
import { performance } from 'node:perf_hooks';
|
||||
import timers from 'node:timers';
|
||||
import timersPromises from 'node:timers/promises';
|
||||
import util from 'node:util';
|
||||
import { startTests, collectTests } from '@vitest/runner';
|
||||
import { KNOWN_ASSET_TYPES } from 'vite-node/constants';
|
||||
import { installSourcemapsSupport } from 'vite-node/source-map';
|
||||
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../chunks/index.CwejwG0H.js';
|
||||
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from '../chunks/setup-common.Dd054P77.js';
|
||||
import { V as VitestIndex } from '../chunks/index.CdQS2e2Q.js';
|
||||
import { c as closeInspector } from '../chunks/inspector.C914Efll.js';
|
||||
import { g as getWorkerState } from '../chunks/utils.XdZDrNZV.js';
|
||||
import 'chai';
|
||||
import 'node:path';
|
||||
import '../path.js';
|
||||
import 'node:url';
|
||||
import '../chunks/rpc.-pEldfrD.js';
|
||||
import '@vitest/utils';
|
||||
import '../chunks/index.B521nVV-.js';
|
||||
import '../chunks/coverage.DVF1vEu8.js';
|
||||
import '@vitest/snapshot';
|
||||
import '../chunks/vi.bdSIJ99Y.js';
|
||||
import '@vitest/expect';
|
||||
import '@vitest/runner/utils';
|
||||
import '../chunks/_commonjsHelpers.BFTU3MAI.js';
|
||||
import '@vitest/utils/error';
|
||||
import '@vitest/spy';
|
||||
import '@vitest/utils/source-map';
|
||||
import '../chunks/date.Bq6ZW5rf.js';
|
||||
import '../chunks/benchmark.CYdenmiT.js';
|
||||
import 'expect-type';
|
||||
|
||||
async function run(method, files, config, executor) {
|
||||
const workerState = getWorkerState();
|
||||
await setupCommonEnv(config);
|
||||
Object.defineProperty(globalThis, "__vitest_index__", {
|
||||
value: VitestIndex,
|
||||
enumerable: false
|
||||
});
|
||||
if (workerState.environment.transformMode === "web") {
|
||||
const _require = createRequire(import.meta.url);
|
||||
// always mock "required" `css` files, because we cannot process them
|
||||
_require.extensions[".css"] = resolveCss;
|
||||
_require.extensions[".scss"] = resolveCss;
|
||||
_require.extensions[".sass"] = resolveCss;
|
||||
_require.extensions[".less"] = resolveCss;
|
||||
// since we are using Vite, we can assume how these will be resolved
|
||||
KNOWN_ASSET_TYPES.forEach((type) => {
|
||||
_require.extensions[`.${type}`] = resolveAsset;
|
||||
});
|
||||
process.env.SSR = "";
|
||||
} else process.env.SSR = "1";
|
||||
// @ts-expect-error not typed global for patched timers
|
||||
globalThis.__vitest_required__ = {
|
||||
util,
|
||||
timers,
|
||||
timersPromises
|
||||
};
|
||||
installSourcemapsSupport({ getSourceMap: (source) => workerState.moduleCache.getSourceMap(source) });
|
||||
await startCoverageInsideWorker(config.coverage, executor, { isolate: false });
|
||||
if (config.chaiConfig) setupChaiConfig(config.chaiConfig);
|
||||
const [runner, snapshotEnvironment] = await Promise.all([resolveTestRunner(config, executor), resolveSnapshotEnvironment(config, executor)]);
|
||||
config.snapshotOptions.snapshotEnvironment = snapshotEnvironment;
|
||||
runner.getWorkerContext = void 0;
|
||||
workerState.onCancel.then((reason) => {
|
||||
closeInspector(config);
|
||||
runner.cancel?.(reason);
|
||||
});
|
||||
workerState.durations.prepare = performance.now() - workerState.durations.prepare;
|
||||
const { vi } = VitestIndex;
|
||||
for (const file of files) {
|
||||
workerState.filepath = file.filepath;
|
||||
if (method === "run") await startTests([file], runner);
|
||||
else await collectTests([file], runner);
|
||||
// reset after tests, because user might call `vi.setConfig` in setupFile
|
||||
vi.resetConfig();
|
||||
// mocks should not affect different files
|
||||
vi.restoreAllMocks();
|
||||
}
|
||||
await stopCoverageInsideWorker(config.coverage, executor, { isolate: false });
|
||||
}
|
||||
function resolveCss(mod) {
|
||||
mod.exports = "";
|
||||
}
|
||||
function resolveAsset(mod, url) {
|
||||
mod.exports = url;
|
||||
}
|
||||
|
||||
export { run };
|
||||
31
node_modules/vitest/dist/workers/threads.js
generated
vendored
Normal file
31
node_modules/vitest/dist/workers/threads.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import { r as runBaseTests } from '../chunks/base.DfmxU-tU.js';
|
||||
import { a as createThreadsRpcOptions } from '../chunks/utils.CAioKnHs.js';
|
||||
import 'vite-node/client';
|
||||
import '../chunks/execute.B7h3T_Hc.js';
|
||||
import 'node:fs';
|
||||
import 'node:url';
|
||||
import 'node:vm';
|
||||
import '@vitest/utils/error';
|
||||
import 'pathe';
|
||||
import 'vite-node/utils';
|
||||
import '../path.js';
|
||||
import 'node:path';
|
||||
import '@vitest/mocker';
|
||||
import 'node:module';
|
||||
import '@vitest/utils';
|
||||
import '../chunks/utils.XdZDrNZV.js';
|
||||
|
||||
class ThreadsBaseWorker {
|
||||
getRpcOptions(ctx) {
|
||||
return createThreadsRpcOptions(ctx);
|
||||
}
|
||||
runTests(state) {
|
||||
return runBaseTests("run", state);
|
||||
}
|
||||
collectTests(state) {
|
||||
return runBaseTests("collect", state);
|
||||
}
|
||||
}
|
||||
const worker = new ThreadsBaseWorker();
|
||||
|
||||
export { worker as default };
|
||||
47
node_modules/vitest/dist/workers/vmForks.js
generated
vendored
Normal file
47
node_modules/vitest/dist/workers/vmForks.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import v8 from 'node:v8';
|
||||
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.CAioKnHs.js';
|
||||
import { r as runVmTests } from '../chunks/vm.BThCzidc.js';
|
||||
import '@vitest/utils';
|
||||
import 'node:url';
|
||||
import 'node:vm';
|
||||
import 'pathe';
|
||||
import '../path.js';
|
||||
import 'node:path';
|
||||
import '../chunks/console.CtFJOzRO.js';
|
||||
import 'node:console';
|
||||
import 'node:stream';
|
||||
import 'tinyrainbow';
|
||||
import '../chunks/date.Bq6ZW5rf.js';
|
||||
import '../chunks/utils.XdZDrNZV.js';
|
||||
import '../chunks/execute.B7h3T_Hc.js';
|
||||
import 'node:fs';
|
||||
import '@vitest/utils/error';
|
||||
import 'vite-node/client';
|
||||
import 'vite-node/utils';
|
||||
import '@vitest/mocker';
|
||||
import 'node:module';
|
||||
import 'vite-node/constants';
|
||||
|
||||
class ForksVmWorker {
|
||||
getRpcOptions() {
|
||||
return createForksRpcOptions(v8);
|
||||
}
|
||||
async executeTests(method, state) {
|
||||
const exit = process.exit;
|
||||
state.ctx.config = unwrapSerializableConfig(state.ctx.config);
|
||||
try {
|
||||
await runVmTests(method, state);
|
||||
} finally {
|
||||
process.exit = exit;
|
||||
}
|
||||
}
|
||||
runTests(state) {
|
||||
return this.executeTests("run", state);
|
||||
}
|
||||
collectTests(state) {
|
||||
return this.executeTests("collect", state);
|
||||
}
|
||||
}
|
||||
const worker = new ForksVmWorker();
|
||||
|
||||
export { worker as default };
|
||||
37
node_modules/vitest/dist/workers/vmThreads.js
generated
vendored
Normal file
37
node_modules/vitest/dist/workers/vmThreads.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import { a as createThreadsRpcOptions } from '../chunks/utils.CAioKnHs.js';
|
||||
import { r as runVmTests } from '../chunks/vm.BThCzidc.js';
|
||||
import '@vitest/utils';
|
||||
import 'node:url';
|
||||
import 'node:vm';
|
||||
import 'pathe';
|
||||
import '../path.js';
|
||||
import 'node:path';
|
||||
import '../chunks/console.CtFJOzRO.js';
|
||||
import 'node:console';
|
||||
import 'node:stream';
|
||||
import 'tinyrainbow';
|
||||
import '../chunks/date.Bq6ZW5rf.js';
|
||||
import '../chunks/utils.XdZDrNZV.js';
|
||||
import '../chunks/execute.B7h3T_Hc.js';
|
||||
import 'node:fs';
|
||||
import '@vitest/utils/error';
|
||||
import 'vite-node/client';
|
||||
import 'vite-node/utils';
|
||||
import '@vitest/mocker';
|
||||
import 'node:module';
|
||||
import 'vite-node/constants';
|
||||
|
||||
class ThreadsVmWorker {
|
||||
getRpcOptions(ctx) {
|
||||
return createThreadsRpcOptions(ctx);
|
||||
}
|
||||
runTests(state) {
|
||||
return runVmTests("run", state);
|
||||
}
|
||||
collectTests(state) {
|
||||
return runVmTests("collect", state);
|
||||
}
|
||||
}
|
||||
const worker = new ThreadsVmWorker();
|
||||
|
||||
export { worker as default };
|
||||
1
node_modules/vitest/environments.d.ts
generated
vendored
Normal file
1
node_modules/vitest/environments.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/environments'
|
||||
1
node_modules/vitest/execute.d.ts
generated
vendored
Normal file
1
node_modules/vitest/execute.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/execute.js'
|
||||
20
node_modules/vitest/globals.d.ts
generated
vendored
Normal file
20
node_modules/vitest/globals.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
declare global {
|
||||
const suite: typeof import('vitest')['suite']
|
||||
const test: typeof import('vitest')['test']
|
||||
const chai: typeof import("vitest")["chai"]
|
||||
const describe: typeof import('vitest')['describe']
|
||||
const it: typeof import('vitest')['it']
|
||||
const expectTypeOf: typeof import('vitest')['expectTypeOf']
|
||||
const assertType: typeof import('vitest')['assertType']
|
||||
const expect: typeof import('vitest')['expect']
|
||||
const assert: typeof import('vitest')['assert']
|
||||
const vitest: typeof import('vitest')['vitest']
|
||||
const vi: typeof import('vitest')['vitest']
|
||||
const beforeAll: typeof import('vitest')['beforeAll']
|
||||
const afterAll: typeof import('vitest')['afterAll']
|
||||
const beforeEach: typeof import('vitest')['beforeEach']
|
||||
const afterEach: typeof import('vitest')['afterEach']
|
||||
const onTestFailed: typeof import('vitest')['onTestFailed']
|
||||
const onTestFinished: typeof import('vitest')['onTestFinished']
|
||||
}
|
||||
export {}
|
||||
5
node_modules/vitest/import-meta.d.ts
generated
vendored
Normal file
5
node_modules/vitest/import-meta.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/// <reference path="./importMeta.d.ts" />
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/45096
|
||||
// TypeScript has a bug that makes <reference types="vite/types/importMeta" />
|
||||
// not possible in userland. This file provides a workaround for now.
|
||||
4
node_modules/vitest/importMeta.d.ts
generated
vendored
Normal file
4
node_modules/vitest/importMeta.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
interface ImportMeta {
|
||||
url: string
|
||||
readonly vitest?: typeof import('vitest')
|
||||
}
|
||||
5
node_modules/vitest/index.cjs
generated
vendored
Normal file
5
node_modules/vitest/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
throw new Error(
|
||||
'Vitest cannot be imported in a CommonJS module using require(). Please use "import" instead.'
|
||||
+ '\n\nIf you are using "import" in your source code, then it\'s possible it was bundled into require() automatically by your bundler. '
|
||||
+ 'In that case, do not bundle CommonJS output since it will never work with Vitest, or use dynamic import() which is available in all CommonJS modules.',
|
||||
)
|
||||
1
node_modules/vitest/index.d.cts
generated
vendored
Normal file
1
node_modules/vitest/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/index.js'
|
||||
6
node_modules/vitest/jsdom.d.ts
generated
vendored
Normal file
6
node_modules/vitest/jsdom.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { JSDOM } from 'jsdom'
|
||||
|
||||
declare global {
|
||||
const jsdom: JSDOM
|
||||
}
|
||||
export {}
|
||||
1
node_modules/vitest/mocker.d.ts
generated
vendored
Normal file
1
node_modules/vitest/mocker.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/mocker.js'
|
||||
1
node_modules/vitest/node.d.ts
generated
vendored
Normal file
1
node_modules/vitest/node.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/node.js'
|
||||
7
node_modules/vitest/optional-types.d.ts
generated
vendored
Normal file
7
node_modules/vitest/optional-types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/* eslint-disable ts/ban-ts-comment */
|
||||
|
||||
// @ts-ignore optional peer dep
|
||||
export type * as jsdomTypes from 'jsdom'
|
||||
|
||||
// @ts-ignore optional peer dep
|
||||
export type * as happyDomTypes from 'happy-dom'
|
||||
207
node_modules/vitest/package.json
generated
vendored
Normal file
207
node_modules/vitest/package.json
generated
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
{
|
||||
"name": "vitest",
|
||||
"type": "module",
|
||||
"version": "3.2.6",
|
||||
"description": "Next generation testing framework powered by Vite",
|
||||
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
||||
"license": "MIT",
|
||||
"funding": "https://opencollective.com/vitest",
|
||||
"homepage": "https://github.com/vitest-dev/vitest#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/vitest-dev/vitest.git",
|
||||
"directory": "packages/vitest"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/vitest-dev/vitest/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"vite",
|
||||
"vitest",
|
||||
"test",
|
||||
"jest"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./index.d.cts",
|
||||
"default": "./index.cjs"
|
||||
}
|
||||
},
|
||||
"./*": "./*",
|
||||
"./globals": {
|
||||
"types": "./globals.d.ts"
|
||||
},
|
||||
"./jsdom": {
|
||||
"types": "./jsdom.d.ts"
|
||||
},
|
||||
"./importMeta": {
|
||||
"types": "./importMeta.d.ts"
|
||||
},
|
||||
"./import-meta": {
|
||||
"types": "./import-meta.d.ts"
|
||||
},
|
||||
"./node": {
|
||||
"types": "./dist/node.d.ts",
|
||||
"default": "./dist/node.js"
|
||||
},
|
||||
"./execute": {
|
||||
"types": "./dist/execute.d.ts",
|
||||
"default": "./dist/execute.js"
|
||||
},
|
||||
"./workers": {
|
||||
"types": "./dist/workers.d.ts",
|
||||
"import": "./dist/workers.js"
|
||||
},
|
||||
"./internal/browser": {
|
||||
"types": "./dist/browser.d.ts",
|
||||
"default": "./dist/browser.js"
|
||||
},
|
||||
"./runners": {
|
||||
"types": "./dist/runners.d.ts",
|
||||
"default": "./dist/runners.js"
|
||||
},
|
||||
"./suite": {
|
||||
"types": "./dist/suite.d.ts",
|
||||
"default": "./dist/suite.js"
|
||||
},
|
||||
"./environments": {
|
||||
"types": "./dist/environments.d.ts",
|
||||
"default": "./dist/environments.js"
|
||||
},
|
||||
"./config": {
|
||||
"types": "./config.d.ts",
|
||||
"require": "./dist/config.cjs",
|
||||
"default": "./dist/config.js"
|
||||
},
|
||||
"./coverage": {
|
||||
"types": "./coverage.d.ts",
|
||||
"default": "./dist/coverage.js"
|
||||
},
|
||||
"./reporters": {
|
||||
"types": "./dist/reporters.d.ts",
|
||||
"default": "./dist/reporters.js"
|
||||
},
|
||||
"./snapshot": {
|
||||
"types": "./dist/snapshot.d.ts",
|
||||
"default": "./dist/snapshot.js"
|
||||
},
|
||||
"./mocker": {
|
||||
"types": "./dist/mocker.d.ts",
|
||||
"default": "./dist/mocker.js"
|
||||
}
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"bin": {
|
||||
"vitest": "./vitest.mjs"
|
||||
},
|
||||
"files": [
|
||||
"*.cjs",
|
||||
"*.d.cts",
|
||||
"*.d.ts",
|
||||
"*.mjs",
|
||||
"bin",
|
||||
"dist"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^18.0.0 || ^20.0.0 || >=22.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@edge-runtime/vm": "*",
|
||||
"@types/debug": "^4.1.12",
|
||||
"@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0",
|
||||
"happy-dom": "*",
|
||||
"jsdom": "*",
|
||||
"@vitest/browser": "3.2.6",
|
||||
"@vitest/ui": "3.2.6"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@edge-runtime/vm": {
|
||||
"optional": true
|
||||
},
|
||||
"@types/debug": {
|
||||
"optional": true
|
||||
},
|
||||
"@types/node": {
|
||||
"optional": true
|
||||
},
|
||||
"@vitest/browser": {
|
||||
"optional": true
|
||||
},
|
||||
"@vitest/ui": {
|
||||
"optional": true
|
||||
},
|
||||
"happy-dom": {
|
||||
"optional": true
|
||||
},
|
||||
"jsdom": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/chai": "^5.2.2",
|
||||
"chai": "^5.2.0",
|
||||
"debug": "^4.4.1",
|
||||
"expect-type": "^1.2.1",
|
||||
"magic-string": "^0.30.17",
|
||||
"pathe": "^2.0.3",
|
||||
"picomatch": "^4.0.2",
|
||||
"std-env": "^3.9.0",
|
||||
"tinybench": "^2.9.0",
|
||||
"tinyexec": "^0.3.2",
|
||||
"tinyglobby": "^0.2.14",
|
||||
"tinypool": "^1.1.1",
|
||||
"tinyrainbow": "^2.0.0",
|
||||
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0",
|
||||
"vite-node": "3.2.4",
|
||||
"why-is-node-running": "^2.3.0",
|
||||
"@vitest/expect": "3.2.6",
|
||||
"@vitest/pretty-format": "^3.2.6",
|
||||
"@vitest/mocker": "3.2.6",
|
||||
"@vitest/runner": "3.2.6",
|
||||
"@vitest/snapshot": "3.2.6",
|
||||
"@vitest/spy": "3.2.6",
|
||||
"@vitest/utils": "3.2.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ampproject/remapping": "^2.3.0",
|
||||
"@antfu/install-pkg": "^1.1.0",
|
||||
"@edge-runtime/vm": "^5.0.0",
|
||||
"@sinonjs/fake-timers": "14.0.0",
|
||||
"@types/debug": "^4.1.12",
|
||||
"@types/estree": "^1.0.8",
|
||||
"@types/istanbul-lib-coverage": "^2.0.6",
|
||||
"@types/istanbul-reports": "^3.0.4",
|
||||
"@types/jsdom": "^21.1.7",
|
||||
"@types/mime": "^4.0.0",
|
||||
"@types/node": "^22.15.32",
|
||||
"@types/picomatch": "^4.0.0",
|
||||
"@types/prompts": "^2.4.9",
|
||||
"@types/sinonjs__fake-timers": "^8.1.5",
|
||||
"acorn-walk": "^8.3.4",
|
||||
"birpc": "2.4.0",
|
||||
"cac": "^6.7.14",
|
||||
"chai-subset": "^1.6.0",
|
||||
"find-up": "^6.3.0",
|
||||
"flatted": "^3.3.3",
|
||||
"happy-dom": "^17.6.3",
|
||||
"jsdom": "^26.1.0",
|
||||
"local-pkg": "^1.1.1",
|
||||
"mime": "^4.0.7",
|
||||
"pretty-format": "^29.7.0",
|
||||
"prompts": "^2.4.2",
|
||||
"strip-literal": "^3.0.0",
|
||||
"ws": "^8.18.2"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rimraf dist && rollup -c",
|
||||
"dev": "NODE_OPTIONS=\"--max-old-space-size=8192\" rollup -c --watch -m inline"
|
||||
}
|
||||
}
|
||||
1
node_modules/vitest/reporters.d.ts
generated
vendored
Normal file
1
node_modules/vitest/reporters.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/reporters.js'
|
||||
1
node_modules/vitest/runners.d.ts
generated
vendored
Normal file
1
node_modules/vitest/runners.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/runners.js'
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user